Spring 3, Jersey (JSR-311) and Maven dependencies Spring 3, Jersey (JSR-311) and Maven dependencies spring spring

Spring 3, Jersey (JSR-311) and Maven dependencies


Own Answer: I simply excluded the dependencies in the pom.xml in the following way. there don't seem to be any incompabilities and everything runs fine so far:

 <dependency>    <groupId>com.sun.jersey.contribs</groupId>    <artifactId>jersey-spring</artifactId>    <version>1.2</version>    <exclusions>        <exclusion>            <groupId>org.springframework</groupId>            <artifactId>spring</artifactId>        </exclusion>        <exclusion>            <groupId>org.springframework</groupId>            <artifactId>spring-core</artifactId>        </exclusion>        <exclusion>            <groupId>org.springframework</groupId>            <artifactId>spring-web</artifactId>        </exclusion>        <exclusion>            <groupId>org.springframework</groupId>            <artifactId>spring-beans</artifactId>        </exclusion>        <exclusion>            <groupId>org.springframework</groupId>            <artifactId>spring-context</artifactId>        </exclusion>    </exclusions></dependency>


I don't know if jersey-spring is compatible with Spring 3.0 but the way to control the versions of artifacts used in transitive dependencies is to use dependencyManagement:

<project>  ...  <repositories>    <repository>      <id>download-java-net</id>      <url>http://download.java.net/maven/2/</url>    </repository>  </repositories>  <properties>    <org.springframework.version>3.0.2.RELEASE</org.springframework.version>  </properties>  <dependencyManagement>    <dependencies>      <dependency>        <groupId>org.springframework</groupId>        <artifactId>spring-core</artifactId>        <version>${org.springframework.version}</version>      </dependency>      <dependency>        <groupId>org.springframework</groupId>        <artifactId>spring-beans</artifactId>        <version>${org.springframework.version}</version>      </dependency>      <dependency>        <groupId>org.springframework</groupId>        <artifactId>spring-web</artifactId>        <version>${org.springframework.version}</version>      </dependency>      <dependency>        <groupId>org.springframework</groupId>        <artifactId>spring-context</artifactId>        <version>${org.springframework.version}</version>      </dependency>      <dependency>        <groupId>org.springframework</groupId>        <artifactId>spring</artifactId>        <version>${org.springframework.version}</version>      </dependency>    </dependencies>  </dependencyManagement>  <dependencies>    <dependency>      <groupId>com.sun.jersey.contribs</groupId>      <artifactId>jersey-spring</artifactId>      <version>1.2</version>      <exclusions>        <exclusion>          <groupId>org.springframework</groupId>          <artifactId>spring</artifactId>        </exclusion>      </exclusions>    </dependency>    ...  </dependencies></project>

Note that it's still required to exclude org.springframework:spring:jar:2.5.6 since this dependency doesn't exist in later versions.

Below, the dependency tree you'll get with this setup:

$ mvn dependency:tree [INFO] Scanning for projects...[INFO] Searching repository for plugin with prefix: 'dependency'.[INFO] ------------------------------------------------------------------------[INFO] Building Q2911869[INFO]    task-segment: [dependency:tree][INFO] ------------------------------------------------------------------------[INFO] [dependency:tree {execution: default-cli}][INFO] com.stackoverflow:Q2911869:jar:1.0-SNAPSHOT[INFO] +- com.sun.jersey.contribs:jersey-spring:jar:1.2:compile[INFO] |  +- com.sun.jersey:jersey-server:jar:1.2:compile[INFO] |  |  +- com.sun.jersey:jersey-core:jar:1.2:compile[INFO] |  |  |  \- javax.ws.rs:jsr311-api:jar:1.1.1:compile[INFO] |  |  \- asm:asm:jar:3.1:compile[INFO] |  +- org.springframework:spring-core:jar:3.0.2.RELEASE:compile[INFO] |  |  +- org.springframework:spring-asm:jar:3.0.2.RELEASE:compile[INFO] |  |  \- commons-logging:commons-logging:jar:1.1.1:compile[INFO] |  +- org.springframework:spring-beans:jar:3.0.2.RELEASE:compile[INFO] |  +- org.springframework:spring-context:jar:3.0.2.RELEASE:compile[INFO] |  |  +- org.springframework:spring-aop:jar:3.0.2.RELEASE:compile[INFO] |  |  \- org.springframework:spring-expression:jar:3.0.2.RELEASE:compile[INFO] |  \- org.springframework:spring-web:jar:3.0.2.RELEASE:compile[INFO] |     \- aopalliance:aopalliance:jar:1.0:compile[INFO] \- junit:junit:jar:3.8.1:test...

Reference


As far as I know they are yet to officially change the jersey-spring maven module to support spring 3.0 instead of 2.5. I also found the following post at nabble forum!