我有一个父项目包含十几个子项目,其中一个子项目使用org.apache.httpcomponents:httpclient:jar:4.3.5,这取决于org.apache.httpcomponents:httpcore:jar:4.3.2.
但是,结果版本httpcore被解析为4.2.1而不是4.3.2.
以下是dependency:tree在Eclipse中选中调试选项运行时的输出提取:
...
[DEBUG] Using mirror nexus (http://192.168.0.111:8081/nexus/content/groups/public) for apache.snapshots (http://repository.apache.org/snapshots).
[DEBUG] testArtifact: artifact=org.apache.httpcomponents:httpclient:jar:4.3.5:compile
[DEBUG] includeArtifact: artifact=org.apache.httpcomponents:httpclient:jar:4.3.5:compile
[DEBUG] startProcessChildren: artifact=org.apache.httpcomponents:httpclient:jar:4.3.5:compile
[DEBUG] manageArtifactVersion: artifact=org.apache.httpcomponents:httpcore:jar:4.3.2:compile, replacement=org.apache.httpcomponents:httpcore:jar:4.2.1
[DEBUG] Using mirror nexus (http://192.168.0.111:8081/nexus/content/groups/public) for apache.snapshots (http://repository.apache.org/snapshots).
...
Run Code Online (Sandbox Code Playgroud)
它只是显示replacement=org.apache.httpcomponents:httpcore:jar:4.2.1,但它没有说明更换的原因.父项目的pom.xml使用了很多依赖项,即使我可以尝试逐个删除这些依赖项并检查结果,但这将非常耗时.有没有更有效的方法来调试工件更换?
这里几乎是dependency:treeEclipse 的完整日志,并且选中了调试选项.
我遇到了类似于Maven 2的问题- 测试和编译中的不同依赖版本但是指定的答案不起作用.
在我的项目中,我需要依赖于Hadoop的Cloudera发行版和JUnit测试的"vanilla"版本,因为前者仅适用于*nix.
当我尝试执行我的应用程序时,我得到了Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/hadoop/conf/Configuration.当我从Maven或Eclipse运行JUnit测试时,一切正常.如果我注释掉test依赖项,应用程序将成功运行.
为什么在取消注释依赖项compile时会忽略test依赖关系?
<dependency>
<groupId>org.apache.hadoop</groupId>
<artifactId>hadoop-core</artifactId>
<version>0.20.2-cdh3u2</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.apache.hadoop</groupId>
<artifactId>hadoop-core</artifactId>
<version>1.0.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.hadoop</groupId>
<artifactId>hadoop-test</artifactId>
<version>1.0.0</version>
<scope>test</scope>
</dependency>
Run Code Online (Sandbox Code Playgroud)
mvn dependency:list显示以下内容,它根本不显示compile范围版本:
[INFO] The following files have been resolved:
[INFO] ant:ant:jar:1.6.5:test
[INFO] aopalliance:aopalliance:jar:1.0:compile
[INFO] asm:asm:jar:3.3.1:compile
[INFO] cglib:cglib:jar:2.2.2:compile
[INFO] ch.qos.logback:logback-classic:jar:1.0.0:compile
[INFO] ch.qos.logback:logback-core:jar:1.0.0:compile
[INFO] com.google.guava:guava:jar:r08:compile
[INFO] com.h2database:h2:jar:1.3.164:test
[INFO] com.jolbox:bonecp:jar:0.7.1.RELEASE:compile
[INFO] com.sun.jersey:jersey-core:jar:1.11:test
[INFO] commons-beanutils:commons-beanutils:jar:1.7.0:test
[INFO] commons-beanutils:commons-beanutils-core:jar:1.8.0:test
[INFO] commons-cli:commons-cli:jar:1.2:test
[INFO] …Run Code Online (Sandbox Code Playgroud)