我正在使用Spring 4.1并从头开始编写maven模块。我有2个服务模块A和B以及一个webapp,它调用服务A,其实现在模块B中。以下是我父pom中的Spring jar列表。
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>${spring.version}</version>
<exclusions>
<exclusion>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-tx</artifactId>
<version>${spring.version}</version>
<scope>provided</scope>
</dependency>
在遇到这个我解决之前,我遇到了更多问题。所以其中一个帖子也要求下面的依赖项(我不明白为什么我必须提供它,如果spring需要它们为什么它没有包装它。)
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-aspects</artifactId>
<version>${spring.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjrt</artifactId>
<version>${aspect.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjweaver</artifactId>
<version>${aspect.version}</version>
<scope>provided</scope>
</dependency>
我得到了上述问题,其中一篇文章建议排除旧的并包含最新的asm-all依赖的spring-asm。
<dependency>
<groupId>asm</groupId>
<artifactId>asm-all</artifactId>
<version>3.3.1</version>
</dependency>
我删除了spring-asm依赖添加上面的内容。现在我遇到了类不兼容的问题。请建议我如何解决它。
我的完整树是:
--- maven-dependency-plugin:2.8:tree (default-cli) @ testapp ---
com.name:testapp:war:0.0.1-SNAPSHOT
+- org.springframework:spring-web:jar:4.1.0.RELEASE:compile
| \- org.springframework:spring-aop:jar:4.1.0.RELEASE:compile
| \- aopalliance:aopalliance:jar:1.0:compile
+- javax.servlet:javax.servlet-api:jar:3.1.0:compile
+- org.springframework:spring-core:jar:4.1.0.RELEASE:provided
+- org.springframework:spring-context:jar:4.1.0.RELEASE:provided
| \- org.springframework:spring-expression:jar:4.1.0.RELEASE:provided
+- org.springframework:spring-test:jar:4.1.0.RELEASE:compile
+- org.springframework:spring-beans:jar:4.1.0.RELEASE:provided
+- org.springframework:spring-tx:jar:4.1.0.RELEASE:provided
+- org.springframework:spring-aspects:jar:4.1.0.RELEASE:provided
+- org.aspectj:aspectjrt:jar:1.5.4:provided
+- org.aspectj:aspectjweaver:jar:1.5.4:provided
+- org.slf4j:slf4j-api:jar:1.7.7:compile
+- org.slf4j:jcl-over-slf4j:jar:1.7.7:compile
+- ch.qos.logback:logback-core:jar:1.1.2:compile
+- ch.qos.logback:logback-classic:jar:1.1.2:compile
+- com.name:MongoClient-API:jar:0.0.1-SNAPSHOT:compile
| +- org.mongodb:mongo-java-driver:jar:2.12.3:compile
| \- com.name:GenericException:jar:0.0.1-SNAPSHOT:compile
\- com.name:MongoClient-Impl:jar:0.0.1-SNAPSHOT:compile
提前致谢