maven uses mvn maven:tree can not display all dependencies

Viewed 41

Because I need to find all project whose fastjson dependency's version is low 1.2.83,I want to use the order "mvn dependency:tree" to see all of the project's dependencies. But some are successful and some are unsuccessful. There distinction is: the unsuccessful only display those after I run the "mvn dependency:tree": only display a little

D:\code\java\testEast\hello-eastmoney\test02>mvn dependency:tree
[INFO] Scanning for projects...
[INFO]
[INFO] -------------------------< org.example:test02 >-------------------------
[INFO] Building test02 1.0-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-dependency-plugin:2.8:tree (default-cli) @ test02 ---
[INFO] org.example:test02:jar:1.0-SNAPSHOT
[INFO] \- org.apache.dubbo:dubbo-spring-boot-starter:jar:2.7.0:compile
[INFO]    \- org.apache.dubbo:dubbo-spring-boot-autoconfigure:jar:2.7.0:compile
[INFO]       \- org.apache.dubbo:dubbo-spring-boot-autoconfigure-compatible:jar:2.7.0:compile
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  0.530 s
[INFO] Finished at: 2022-07-23T17:07:54+08:00
[INFO] ------------------------------------------------------------------------

and the success is: could see all dependencies

D:\code\java\testEast\hello-eastmoney\test03>mvn dependency:tree
[INFO] Scanning for projects...
[INFO]
[INFO] -------------------------< org.example:test03 >-------------------------
[INFO] Building test03 1.0-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-dependency-plugin:2.8:tree (default-cli) @ test03 ---
[INFO] org.example:test03:jar:1.0-SNAPSHOT
[INFO] \- org.apache.dubbo:dubbo-spring-boot-starter:jar:2.7.8:compile
[INFO]    \- org.apache.dubbo:dubbo-spring-boot-autoconfigure:jar:2.7.8:compile
[INFO]       +- org.apache.dubbo:dubbo-spring-boot-autoconfigure-compatible:jar:2.7.8:compile
[INFO]       \- org.apache.dubbo:dubbo:jar:2.7.8:compile
[INFO]          +- org.springframework:spring-context:jar:4.3.16.RELEASE:compile
[INFO]          |  +- org.springframework:spring-aop:jar:4.3.16.RELEASE:compile
[INFO]          |  +- org.springframework:spring-beans:jar:4.3.16.RELEASE:compile
[INFO]          |  +- org.springframework:spring-core:jar:4.3.16.RELEASE:compile
[INFO]          |  |  \- commons-logging:commons-logging:jar:1.2:compile
[INFO]          |  \- org.springframework:spring-expression:jar:4.3.16.RELEASE:compile
[INFO]          +- com.alibaba.spring:spring-context-support:jar:1.0.8:compile
[INFO]          +- org.javassist:javassist:jar:3.20.0-GA:compile
[INFO]          +- io.netty:netty-all:jar:4.1.25.Final:compile
[INFO]          +- com.google.code.gson:gson:jar:2.8.5:compile
[INFO]          +- org.yaml:snakeyaml:jar:1.20:compile
[INFO]          \- com.alibaba:fastjson:jar:1.2.83:compile
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  0.580 s

At first, I suppose the reason is the diffience dubbo's version of them, but I can find the fastjson and many of other dependenties in all of them by Idea.

Thanks for it!

environment: java : Java8 maven: 3.6.3

1 Answers

On!I found the reason. This's because the Dubbo of 2.7.0 version's fastjson dependency is add the <optional>true</optional>, then the maven will do not get the fastjson in their parents.So the fastjson is not display when I run the order mvn dependency:tree on the 2.7.0 version of Dubbo. The benefit is that It can avoid lots of dependency conflicts.

Related