我有一个由 maven 构建的 EAR 文件,目前我有一个 commons 项目,我想将其放入 EAR\lib 中,因此我使用带有 'bundleDir' 标签的 maven-ear-plugin,效果很好,只是现在我的 commons.jar 出现在 lib 文件夹和 EAR 根目录中。我如何告诉它只将其放在 lib 文件夹中?
我的pom:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-ear-plugin</artifactId>
<configuration>
<outputDirectory>../../outputs/java</outputDirectory>
<version>5</version>
<modules>
<jarModule>
<groupId>com.sample.common</groupId>
<artifactId>common</artifactId>
<includeInApplicationXml>
true
</includeInApplicationXml>
<bundleDir>/lib</bundleDir>
</jarModule>
...
</modules>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>ear</goal>
</goals>
</execution>
</executions>
</plugin>
这是依赖关系定义:
<dependency>
<groupId>com.sample.common</groupId>
<artifactId>common</artifactId>
<version>1.0</version>
<scope>provided</scope>
</dependency>
最佳答案
如果你的jar文件不是ejb,你可以简单地将它放入ear依赖项中,而不需要定义到maven-ear-plugin中。否则,请尝试在依赖项列表中设置提供给 jar 的范围。这可能会有所帮助。
关于java - 如何防止 Maven 在 EAR 文件中复制 jar?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9556240/