Java Maven:模块之间的依赖关系不同
我有一个无法解释的奇怪问题:我有三个模块,hadatacollector fhem api、hadatacollector服务和hadatacollector服务器独立。第一个使用gson,下面是mvn dependency:tree的输出:Java Maven:模块之间的依赖关系不同,java,maven,dependencies,Java,Maven,Dependencies,我有一个无法解释的奇怪问题:我有三个模块,hadatacollector fhem api、hadatacollector服务和hadatacollector服务器独立。第一个使用gson,下面是mvn dependency:tree的输出: de.swm.ha:hadatacollector-fhem-api:jar:1.0-SNAPSHOT +- org.slf4j:slf4j-log4j12:jar:1.7.7:compile +- org.slf4j:slf4j-api:jar:1.7.
de.swm.ha:hadatacollector-fhem-api:jar:1.0-SNAPSHOT
+- org.slf4j:slf4j-log4j12:jar:1.7.7:compile
+- org.slf4j:slf4j-api:jar:1.7.7:compile
+- log4j:log4j:jar:1.2.17:compile
\- com.google.code.gson:gson:jar:2.3.1:compile
可以看出,它使用了gson 2.3.1。第二个模块使用第一个模块,以下是各自的依赖关系:
de.swm.ha:hadatacollector-service:jar:1.0-SNAPSHOT
+- de.swm.ha:hadatacollector-model:jar:1.0-SNAPSHOT:compile
| +- org.hibernate.javax.persistence:hibernate-jpa-2.1-api:jar:1.0.0.Final:compile
| \- com.google.guava:guava:jar:18.0:compile
+- de.swm.ha:hadatacollector-persistence:jar:1.0-SNAPSHOT:compile
| +- org.slf4j:slf4j-log4j12:jar:1.7.7:compile
| +- org.slf4j:slf4j-api:jar:1.7.7:compile
| +- log4j:log4j:jar:1.2.17:compile
| +- org.springframework:spring-context:jar:4.1.4.RELEASE:compile
| | +- org.springframework:spring-aop:jar:4.1.4.RELEASE:compile
| | | \- aopalliance:aopalliance:jar:1.0:compile
| | +- org.springframework:spring-beans:jar:4.1.4.RELEASE:compile
| | \- org.springframework:spring-expression:jar:4.1.4.RELEASE:compile
| \- org.springframework:spring-tx:jar:4.1.4.RELEASE:compile
+- de.swm.ha:hadatacollector-fhem-api:jar:1.0-SNAPSHOT:compile
| \- com.google.code.gson:gson:jar:2.3.1:compile
\- org.springframework.boot:spring-boot:jar:1.2.1.RELEASE:compile
\- org.springframework:spring-core:jar:4.1.4.RELEASE:compile
\- commons-logging:commons-logging:jar:1.2:compile
此处也使用gson 2.3.1。但是,第三个模块使用第二个模块,现在输出为:
de.swm.ha:hadatacollector-server-standalone:jar:1.0-SNAPSHOT
+- de.swm.ha:hadatacollector-model:jar:1.0-SNAPSHOT:compile
| +- org.hibernate.javax.persistence:hibernate-jpa-2.1-api:jar:1.0.0.Final:compile
| \- com.google.guava:guava:jar:18.0:compile
+- de.swm.ha:hadatacollector-persistence:jar:1.0-SNAPSHOT:compile
| +- org.springframework:spring-context:jar:4.1.4.RELEASE:compile
| | +- org.springframework:spring-aop:jar:4.1.4.RELEASE:compile
| | | \- aopalliance:aopalliance:jar:1.0:compile
| | +- org.springframework:spring-beans:jar:4.1.4.RELEASE:compile
| | \- org.springframework:spring-expression:jar:4.1.4.RELEASE:compile
| \- org.springframework:spring-tx:jar:4.1.4.RELEASE:compile
+- de.swm.ha:hadatacollector-service:jar:1.0-SNAPSHOT:compile
| +- de.swm.ha:hadatacollector-fhem-api:jar:1.0-SNAPSHOT:compile
| | \- com.google.code.gson:gson:jar:2.3:compile
| \- org.springframework.boot:spring-boot:jar:1.2.1.RELEASE:compile
+- de.swm.ha:hadatacollector-util:jar:1.0-SNAPSHOT:compile
+- org.slf4j:slf4j-log4j12:jar:1.7.7:compile
+- org.slf4j:slf4j-api:jar:1.7.7:compile
+- log4j:log4j:jar:1.2.17:compile
+- org.springframework.boot:spring-boot-starter:jar:1.2.1.RELEASE:compile
| +- org.springframework:spring-core:jar:4.1.4.RELEASE:compile
| \- org.yaml:snakeyaml:jar:1.14:runtime
+- org.springframework.boot:spring-boot-starter-data-jpa:jar:1.2.1.RELEASE:compile
| +- org.springframework.boot:spring-boot-starter- aop:jar:1.2.1.RELEASE:compile
| | +- org.aspectj:aspectjrt:jar:1.8.4:compile
| | \- org.aspectj:aspectjweaver:jar:1.8.4:compile
| +- org.hibernate:hibernate-entitymanager:jar:4.3.7.Final:compile
| | +- org.jboss.logging:jboss-logging:jar:3.1.3.GA:compile
| | +- org.jboss.logging:jboss-logging-annotations:jar:1.2.0.Beta1:compile
| | +- org.hibernate:hibernate-core:jar:4.3.7.Final:compile
| | | +- antlr:antlr:jar:2.7.7:compile
| | | \- org.jboss:jandex:jar:1.1.0.Final:compile
| | +- dom4j:dom4j:jar:1.6.1:compile
| | | \- xml-apis:xml-apis:jar:1.0.b2:compile
| | +- org.hibernate.common:hibernate-commons-annotations:jar:4.0.5.Final:compile
| | \- org.javassist:javassist:jar:3.18.1-GA:compile
| +- javax.transaction:javax.transaction-api:jar:1.2:compile
| +- org.springframework:spring-orm:jar:4.1.4.RELEASE:compile
| +- org.springframework.data:spring-data-jpa:jar:1.7.1.RELEASE:compile
| | +- org.springframework.data:spring-data-commons:jar:1.9.1.RELEASE:compile
| | \- org.slf4j:jcl-over-slf4j:jar:1.7.8:runtime
| \- org.springframework:spring-aspects:jar:4.1.4.RELEASE:compile
+- org.springframework.boot:spring-boot-starter-jdbc:jar:1.2.1.RELEASE:compile
| +- org.springframework:spring-jdbc:jar:4.1.4.RELEASE:compile
| \- org.apache.tomcat:tomcat-jdbc:jar:8.0.15:compile
| \- org.apache.tomcat:tomcat-juli:jar:8.0.15:compile
+- org.springframework.boot:spring-boot-autoconfigure:jar:1.2.1.RELEASE:compile
\- mysql:mysql-connector-java:jar:5.1.34:compile
现在使用的是gson 2.3。我检查了其他依赖项,没有一个使用gson。最后一个模块如何使用与其依赖模块不同的gson版本
更新:添加了完整的依赖关系树。在您的服务中:jar pom.xml可能有gson依赖关系2.3。您是否也可以发布pom.xml的依赖项解析依赖于依赖项顺序,因此请检查第3页是否有其他依赖项。我已经添加了完整的依赖项。它表明hadatacollector fhem api使用gson,但是版本不同。