我试图从我的 EAR 中排除通过 Maven 构建的单个库 .JAR 文件,因为该库作为 JBoss EAP 模块包含在内。我已按照文档中的说明进行操作,但无论如何我总是看到包含该库。相关的 pom.xml 部分如下所示:
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-ear-plugin</artifactId>
<version>2.9</version>
<configuration>
<!-- Tell Maven we are using Java EE 6 -->
<version>6</version>
<finalName>MenuProject</finalName>
<!-- Use Java EE ear libraries as needed. Java EE ear libraries are
in easy way to package any libraries needed in the ear, and automatically
have any modules (EJB-JARs and WARs) use them -->
<defaultLibBundleDir>lib</defaultLibBundleDir>
<packagingExcludes>**/postgresql*.jar</packagingExcludes>
<modules>
<!-- Register our War as a web module, and set the context root -->
<webModule>
...
如您所见,我试图将 postgresql*.jar 文件排除在我的 EAR 文件中。但是,当我进行构建时,我仍然看到它。
我是否误解了此功能?还是我做错了?有什么建议吗?
更新:我应该添加,此库被添加为我的应用程序所依赖的另一个库的依赖项。这就是首先引入它的原因。我不需要将它包含在 EAR 中,因为它可以作为 JBoss EAP 模块使用。
最佳答案
将您的依赖项类型包装在项目对象模型 pom
中作为类型:
<dependency>
<groupId>${project.that.has.postgres.as.dependency.groupId}</groupId>
<artifactId>${project.that.has.postgres.as.dependency.artifactId}</artifactId>
<version>${project.that.has.postgres.as.dependency.version}</version>
<type>pom</type>
</dependency>
关于java - Maven EAR 项目 - JAR 未被排除?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22457247/