Problem
Maven exclusions, configured using dependentWarExcludes in pom.xml, are not respected by IntelliJ IDEA when deploying an exploded WAR artifact. This results in undesired JAR files being included in the deployment.
Cause
IntelliJ IDEA’s "exploded WAR" artifacts do not execute the Maven WAR plugin. As a result, Maven-specific configurations such as overlays and dependentWarExcludes are ignored during artifact building and deployment within the IDE.
Resolution
Option 1: Delegate Build and Run Actions to Maven
Delegating build and run actions to Maven allows IntelliJ IDEA to respect Maven overlays and exclusions.
Steps to enable Maven delegation:
- Navigate to Settings | Build, Execution, Deployment | Build Tools | Maven | Runner
- Select Delegate IDE build/run actions to Maven.
- Save the settings.
Ensure the Maven output matches the expected deployment requirements.
Option 2: Use External Source for Deployment
Manually configure the application server to use the exploded directory produced by Maven for deployment:
- Go to Run > Edit Configurations > Your server > Deployment
- Under Deployments, click the
+icon, then select External source. - Point the deployment source to the
target/directory containing the exploded WAR. - Configure the Before launch section to include a Maven goal:
- Select
+ Run Maven Goal. - Specify
war:exploded(add-DskipTeststo skip tests).
- Select
Option 3: Modify Dependency Exclusions in pom.xml
Adjust Maven dependency configurations to exclude undesired JARs or mark specific dependencies with the provided scope to prevent packaging.
Example:
<dependency>
<groupId>com.example</groupId>
<artifactId>some-lib</artifactId>
<version>${some-lib.version}</version>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
</exclusion>
</exclusions>
</dependency>
Additional Configuration for "Publish on the Fly"
- Enable automatic make:
- Settings > Build, Execution, Deployment > Compiler: 'Build project automatically'
- Settings > Build, Execution, Deployment > Build Tools: 'Sync project after changes in the build scripts'
- Settings > Advanced Settings: 'Allow auto-make to start even if the application is running'
- In your server Run/Debug configuration:
- On ‘Update’ action: Update classes and resources
- (optional) On frame deactivation: Update classes and resources
Comments
0 comments
Please sign in to leave a comment.