要将 Spring 依赖项解析为所需版本,必须在 pom 中显式设置它们,如下所示:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>lorem</groupId>
<artifactId>ipsum</artifactId>
<version>0.0.1-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-core</artifactId>
<version>2.6.1</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-frontend-jaxrs</artifactId>
<version>2.6.1</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-bundle</artifactId>
<version>2.6.1</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-aop</artifactId>
<version>3.1.2.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-asm</artifactId>
<version>3.1.2.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId>
<version>3.1.2.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>3.1.2.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>3.1.2.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-expression</artifactId>
<version>3.1.2.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jms</artifactId>
<version>3.1.2.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-tx</artifactId>
<version>3.1.2.RELEASE</version>
</dependency>
</dependencies>
</project>
这将解决:
...
[INFO] org.springframework:spring-aop:jar:3.1.2.RELEASE:compile
[INFO] org.springframework:spring-asm:jar:3.1.2.RELEASE:compile
[INFO] org.springframework:spring-beans:jar:3.1.2.RELEASE:compile
[INFO] org.springframework:spring-context:jar:3.1.2.RELEASE:compile
[INFO] org.springframework:spring-core:jar:3.1.2.RELEASE:compile
[INFO] org.springframework:spring-expression:jar:3.1.2.RELEASE:compile
[INFO] org.springframework:spring-jms:jar:3.1.2.RELEASE:compile
[INFO] org.springframework:spring-tx:jar:3.1.2.RELEASE:compile
...
为什么要依赖 cxf-bundle?您是否在 OSGi 环境中运行?
cxf-bundle 导入包
org.springframework*;resolution:=optional;version="[2.5,4)"
如果在容器中部署了最新的 Spring 版本应该没问题(至少我会尝试)。