1

我们的项目使用以下 cxf 依赖项:

    <dependency>
        <groupId>org.apache.cxf</groupId>
        <artifactId>cxf-rt-core</artifactId>
    </dependency>
    <dependency>
        <groupId>org.apache.cxf</groupId>
        <artifactId>cxf-rt-frontend-jaxrs</artifactId>
        </dependency>
    <dependency>
        <groupId>org.apache.cxf</groupId>
        <artifactId>cxf-bundle</artifactId>
    </dependency>

我们正在使用最新的cxf 2.6.1. 但是,该cxf-bundle库依赖于Spring 3.0.7.RELEASE库,这与我们的Spring 3.1.2.RELEASE库冲突,这是理解我们基于注释的 ORM 配置类所必需的。

有没有人有一个很好的解决方案来解决这个问题?

4

1 回答 1

1

要将 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 版本应该没问题(至少我会尝试)。

于 2012-09-10T20:16:52.503 回答