传递Maven依赖项显示在依赖项中:树,但不在lib目录中(Transitive Maven dependency shows up in dependency:tree but not in lib directory) 您所在的位置:网站首页 maven显示依赖树 传递Maven依赖项显示在依赖项中:树,但不在lib目录中(Transitive Maven dependency shows up in dependency:tree but not in lib directory)

传递Maven依赖项显示在依赖项中:树,但不在lib目录中(Transitive Maven dependency shows up in dependency:tree but not in lib directory)

2023-03-27 03:17| 来源: 网络整理| 查看: 265

我正在使用Maven 3.0.3来构建一个大的Java项目。 我的pom.xml有一个父类,它依赖于spring-context (编译范围),而这又取决于spring-expression (也在编译范围中)。 当我使用mvn:dependencyTree创建一个依赖关系树时 ,一切看起来都不错, spring-expression库在编译范围内变成传递依赖关系。 然而,如果我用mvn help:effective-pom建立一个有效的pom mvn help:effective-pom缺少了spring-expression的入口。 另外,如果我构建项目,则用于spring-expression的lib不包含在lib目录中,而用于spring-context包含在。

直到最近该库被包含在构建中,现在某些依赖关系中的某些东西似乎已经发生了变化。 但是, spring-context仍然在编译范围内,并显示在依赖关系树中,所以我不明白为什么这应该改变了行为。

另外,更新Maven(这似乎解决了一个可能相关的问题在这里 )可悲的是不是一个选项。 我已经通过将spring-expression作为直接而不是传递性的依赖项添加到我的项目中来临时解决了这个问题,但我宁愿不要将应该已经存在的东西阻塞在pom上。 有任何想法吗?

更新: Weirder和weirder ...虽然试图拿出一个最小的例子,我发现了一种。 这就是我想到的:

4.0.0 org.test.project test-project war 0.1-SNAPSHOT Test Project 3.2.4.RELEASE org.springframework spring-context ${spring.version} runtime

它的工作原理是传递依赖关系spring-expression显示在mvn:dependencyTree的输出中:

[INFO] Scanning for projects... [INFO] [INFO] ------------------------------------------------------------------------ [INFO] Building Test Project 0.1-SNAPSHOT [INFO] ------------------------------------------------------------------------ [INFO] [INFO] --- maven-dependency-plugin:2.1:tree (default-cli) @ test-project --- [INFO] org.test.project:test-project:war:0.1-SNAPSHOT [INFO] \- org.springframework:spring-context:jar:3.2.4.RELEASE:runtime [INFO] +- org.springframework:spring-aop:jar:3.2.4.RELEASE:runtime [INFO] | \- aopalliance:aopalliance:jar:1.0:runtime [INFO] +- org.springframework:spring-beans:jar:3.2.4.RELEASE:runtime [INFO] +- org.springframework:spring-core:jar:3.2.4.RELEASE:runtime [INFO] | \- commons-logging:commons-logging:jar:1.1.1:runtime [INFO] \- org.springframework:spring-expression:jar:3.2.4.RELEASE:runtime [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESS [INFO] ------------------------------------------------------------------------ [INFO] Total time: 0.922s [INFO] Finished at: Thu Apr 10 16:17:42 CEST 2014 [INFO] Final Memory: 5M/15M [INFO] ------------------------------------------------------------------------

而不是在有效的POM中:

4.0.0 org.test.project test-project 0.1-SNAPSHOT war Test Project internal_repo Repository for internal artefacts http://internal/url internal_repo Repository for internal artefacts http://internal/url true true 3.2.4.RELEASE org.springframework spring-context 3.2.4.RELEASE runtime true true central http://internal/url true true maven3 http://internal/url true true central http://internal/url true true maven3 http://internal/url c:\projects\test-project\src\main\java c:\projects\test-project\src\main\scripts c:\projects\test-project\src\test\java c:\projects\test-project\target\classes c:\projects\test-project\target\test-classes c:\projects\test-project\src\main\resources c:\projects\test-project\src\test\resources c:\projects\test-project\target test-project-0.1-SNAPSHOT maven-antrun-plugin 1.3 maven-assembly-plugin 2.2-beta-5 maven-dependency-plugin 2.1 maven-release-plugin 2.0 maven-clean-plugin 2.4.1 default-clean clean clean maven-install-plugin 2.3.1 default-install install install maven-resources-plugin 2.4.3 default-resources process-resources resources default-testResources process-test-resources testResources maven-surefire-plugin 2.7.2 default-test test test maven-compiler-plugin 2.3.2 default-testCompile test-compile testCompile default-compile compile compile maven-war-plugin 2.1.1 default-war package war maven-deploy-plugin 2.5 default-deploy deploy deploy maven-site-plugin 2.0.1 default-site site site c:\projects\test-project\target\site org.apache.maven.plugins maven-project-info-reports-plugin default-deploy site-deploy deploy c:\projects\test-project\target\site org.apache.maven.plugins maven-project-info-reports-plugin c:\projects\test-project\target\site org.apache.maven.plugins maven-project-info-reports-plugin c:\projects\test-project\target\site

但是,当我构建项目时,lib目录在本例中包含spring-expression 。 怎么会这样?

I am using Maven 3.0.3 to build a large java project. My pom.xml has a parent which depends on spring-context (compile scope) which in turn depends on spring-expression (also in the compile scope). When I create a dependency tree with mvn:dependencyTree everything looks fine, the spring-expression library turns up as a transitive dependency in compile scope. However if I build an effective pom with mvn help:effective-pom the entry for spring-expression is missing. Also if I build the project the lib for spring-expression is not included in the lib directory while the one for spring-context is.

Until recently the library was included in the build, now something seems to have changed in one of the dependencies. However spring-context is still in the compile scope and shows up in the dependency tree, so I don't see why this should have changed the behavior.

Also, updating Maven (which seems to have solved a possibly related problem here) is sadly not an option. I have temporarily fixed the problem by adding spring-expression as a direct rather than transitive dependency to my project but I'd rather not clog up the pom with stuff that should already be there. Any ideas?

Update: Weirder and weirder... While trying to come up with a minimal example I found one - sort of. This is what I came up with:

4.0.0 org.test.project test-project war 0.1-SNAPSHOT Test Project 3.2.4.RELEASE org.springframework spring-context ${spring.version} runtime

It works in that the transitive dependency spring-expression is shown in the output of mvn:dependencyTree:

[INFO] Scanning for projects... [INFO] [INFO] ------------------------------------------------------------------------ [INFO] Building Test Project 0.1-SNAPSHOT [INFO] ------------------------------------------------------------------------ [INFO] [INFO] --- maven-dependency-plugin:2.1:tree (default-cli) @ test-project --- [INFO] org.test.project:test-project:war:0.1-SNAPSHOT [INFO] \- org.springframework:spring-context:jar:3.2.4.RELEASE:runtime [INFO] +- org.springframework:spring-aop:jar:3.2.4.RELEASE:runtime [INFO] | \- aopalliance:aopalliance:jar:1.0:runtime [INFO] +- org.springframework:spring-beans:jar:3.2.4.RELEASE:runtime [INFO] +- org.springframework:spring-core:jar:3.2.4.RELEASE:runtime [INFO] | \- commons-logging:commons-logging:jar:1.1.1:runtime [INFO] \- org.springframework:spring-expression:jar:3.2.4.RELEASE:runtime [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESS [INFO] ------------------------------------------------------------------------ [INFO] Total time: 0.922s [INFO] Finished at: Thu Apr 10 16:17:42 CEST 2014 [INFO] Final Memory: 5M/15M [INFO] ------------------------------------------------------------------------

and not in the effective pom:

4.0.0 org.test.project test-project 0.1-SNAPSHOT war Test Project internal_repo Repository for internal artefacts http://internal/url internal_repo Repository for internal artefacts http://internal/url true true 3.2.4.RELEASE org.springframework spring-context 3.2.4.RELEASE runtime true true central http://internal/url true true maven3 http://internal/url true true central http://internal/url true true maven3 http://internal/url c:\projects\test-project\src\main\java c:\projects\test-project\src\main\scripts c:\projects\test-project\src\test\java c:\projects\test-project\target\classes c:\projects\test-project\target\test-classes c:\projects\test-project\src\main\resources c:\projects\test-project\src\test\resources c:\projects\test-project\target test-project-0.1-SNAPSHOT maven-antrun-plugin 1.3 maven-assembly-plugin 2.2-beta-5 maven-dependency-plugin 2.1 maven-release-plugin 2.0 maven-clean-plugin 2.4.1 default-clean clean clean maven-install-plugin 2.3.1 default-install install install maven-resources-plugin 2.4.3 default-resources process-resources resources default-testResources process-test-resources testResources maven-surefire-plugin 2.7.2 default-test test test maven-compiler-plugin 2.3.2 default-testCompile test-compile testCompile default-compile compile compile maven-war-plugin 2.1.1 default-war package war maven-deploy-plugin 2.5 default-deploy deploy deploy maven-site-plugin 2.0.1 default-site site site c:\projects\test-project\target\site org.apache.maven.plugins maven-project-info-reports-plugin default-deploy site-deploy deploy c:\projects\test-project\target\site org.apache.maven.plugins maven-project-info-reports-plugin c:\projects\test-project\target\site org.apache.maven.plugins maven-project-info-reports-plugin c:\projects\test-project\target\site

However when I build the project the lib directory does include spring-expression in this example. How can this be?



【本文地址】

公司简介

联系我们

今日新闻

    推荐新闻

    专题文章
      CopyRight 2018-2019 实验室设备网 版权所有