java - Maven EAR 项目 - JAR 未被排除?

标签 java maven jar jboss ear

我试图从我的 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/

相关文章:

maven - IntelliJ 如何从 pom 文件创建 Artifact ?

java - 在外部 Maven 项目中引用/使用文件

java - 获取文件夹路径

java - 在 jar 中的 jar 中获取文件

java - 剪刀石头布。 java 。方法

java - servlet 和 web 服务之间的区别

spring - 使用集成的 Tomcat 部署 Maven 项目

java - 如何在 java 中配置和使用 KStem?

java - 接收参数的 CDI 验证

java - 不同包下的两个不同 jar 中的相同类。它会导致应用程序执行出现任何问题吗?