Maven构建与依赖树不同 [英] Maven Build different to Dependency Tree

查看:189
本文介绍了Maven构建与依赖树不同的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Maven 3构建具有3个层的Java应用程序-服务器,ejb和ui. EJB项目依赖于Server项目,而UI项目仅依赖于EJB,并且排除了Server传递依赖项.

I am using Maven 3 to build a java application with 3 tiers - server, ejb and ui. The EJB project is dependent on the Server project, and the UI project is only dependent on EJB, and provides an exclusion for the Server transitive dependency.

将UI项目构建为战争时,尽管服务器依赖项未显示在dependency:tree命令中,但仍包含服务器依赖项.

When the UI project is built as a war, the Server dependency is being included despite it not showing up on dependency:tree command.

这是运行mvn dependency:tree

**project.name:UI:war:1.0 SNAPSHOT**
+-  project.name:Common:jar:1.0 SNAPSHOT:compile
|   +  org_common:_lib:jar:16.0.006:compile
|   |  +- log4j:log4j:jar:1.2.16:compile
|   |  \- commons configuration:commons configuration:jar:1.6:compile
|   |     +- commons lang:commons lang:jar:2.4:compile
|   |     +- commons digester:commons digester:jar:1.8:compile
|   |     \- commons beanutils:commons beanutils core:jar:1.8.0:compile
|   +- org_common:_security_lib:jar:16.0.006:compile
|   \- org.springframework:spring:jar:2.0:compile
+-  **project.name:EJB:ejb client:client:1.0 SNAPSHOT:compile**
|   \- com.ibm.websphere.appserver:j2ee:jar:7.0.0.9:compile
+-  org_common:_uicomponent:jar:16.0.006:compile

这是运行mvn clean install -X

**project.name:UI:war:1.0 SNAPSHOT**
+-  project.name:Common:jar:1.0 SNAPSHOT:compile
|   +  org_common:_lib:jar:16.0.006:compile
|   |  +- log4j:log4j:jar:1.2.16:compile
|   |  \- commons configuration:commons configuration:jar:1.6:compile
|   |     +- commons lang:commons lang:jar:2.4:compile
|   |     +- commons digester:commons digester:jar:1.8:compile
|   |     \- commons beanutils:commons beanutils core:jar:1.8.0:compile
|   +- org_common:_security_lib:jar:16.0.006:compile
|   \- org.springframework:spring:jar:2.0:compile
+-  **project.name:EJB:ejb client:client:1.0 SNAPSHOT:compile**
|   +- **project.name:Server:jar:1.0 SNAPSHOT:compile**
|   |   +- javassist:javassist:jar:3.4.GA:compile
|   |   +- project.filestore:filestore_client:jar:7.0.003:compile
|   |   +- com.ibm.db2:db2jcc:jar:9.7.fp1.aix64.s091114:compile
|   |   +- com.ibm.db2:db2java:jar:9.7.fp1.aix64.s091114:compile
|   |   +- com.ibm.db2:db2jcc_license_cu:jar:9.7.fp1.aix64.s091114:compile
|   \- com.ibm.websphere.appserver:j2ee:jar:7.0.0.9:compile
+-  org_common:_uicomponent:jar:16.0.006:compile

对服务器的依赖性是两棵树之间的唯一区别. 这两个输出不应该总是相同的吗?是什么原因导致包含的库未出现在dependency:tree中?

The dependency on Server is the only difference between the two trees. Shouldn't these two outputs always be the same? What could cause a library to be included that does not show up in dependency:tree?

父POM将模块定义为:

The parent POM defines the modules as:

<modules>
    <module>Server</module>
    <module>EJB</module>
    <module>UI</module>
</modules>

EJB POM中列出的依赖项是:

The dependency listed in the EJB POM is:

<dependencies>
        <dependency>
            <groupId>project.name</groupId>
            <artifactId>Server</artifactId>
            <version>${project.version}</version>
        </dependency>
    </dependencies>

UI中的依赖项为:

<dependencies>
        <dependency>
            <groupId>project.name</groupId>
            <artifactId>EJB</artifactId>
            <version>${project.version}</version>
            <type>ejb-client</type>
            <exclusions>
                <exclusion>
                    <groupId>project.name</groupId>
                    <artifactId>Server</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
</dependencies>

我知道我可以明确地将Server jar排除在WAR中,但我希望更正实际的问题.

I am aware that I can explicitly exclude the Server jar from being included in the WAR, but I would prefer to fix the actual issue.

推荐答案

正如我们在注释中指出的那样,问题的根源是有问题的Maven 3.0.3. 3.0.4版解决了该问题.

As we figured out in comments, the problem's source was buggy Maven 3.0.3. Version 3.0.4 has solved the issue.

我的评论在那里:

您使用哪个确切的Maven版本?如果不是3.0.4,请尝试一下并确定是否有帮助.在使用以前的Maven 3版本(主要是3.0.2.)时,我发现了非常糟糕的问题.

Which exact Maven version do you use? If not 3.0.4, try it and tell if it helps. I've found really, REALLY crappy issues while using previous Maven 3 releases, mostly with 3.0.2.

这篇关于Maven构建与依赖树不同的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆