0

I have a project which uses spring. It uses version 3.1.1 but, for some reason I really don't know, some spring artifacts are duplicated with two different versions. I look for the those dependencies in all pom.xml files from my project. I also use the dependecy plugin to figure out where were those dependencies included.

Here you have an extract of the output of mvn dependency:tree

[INFO] |  |  \- org.springframework:spring-web:jar:3.1.1.RELEASE:compile
[INFO] |  |     +- aopalliance:aopalliance:jar:1.0:compile
[INFO] |  |     +- org.springframework:spring-beans:jar:3.1.1.RELEASE:compile
[INFO] |  |     +- org.springframework:spring-context:jar:3.1.1.RELEASE:compile
[INFO] |  |     |  +- org.springframework:spring-aop:jar:3.1.1.RELEASE:compile
[INFO] |  |     |  +- org.springframework:spring-expression:jar:3.1.1.RELEASE:compile
[INFO] |  |     |  \- org.springframework:spring-asm:jar:3.0.5.RELEASE:compile
[INFO] |  |     \- org.springframework:spring-core:jar:3.0.5.RELEASE:compile

As far as I know this means that org.springframework:spring-core:jar:3.0.5.RELEASE:compile is included in org.springframework:spring-web:jar:3.1.1.RELEASE:compile.

I workaround this including a dependency with scope provided but I'd need to know why is this happening.

Update: It seems that when I comment the next code the jars are not included in the war.

<dependency>
    <groupId>org.apache.cxf</groupId>
        <artifactId>cxf-rt-frontend-jaxws</artifactId>
    <version>${cxf-version}</version>
</dependency>
...
<properties>
    ...
    <cxf-version>2.4.2</cxf-version>
    <spring.version>3.1.1</spring.version>
</properties>
esauro
  • 1,276
  • 10
  • 17
  • I can't really believe that both versions are actually on the classpath if its the exact same dependency with the same artifact and groupId. Maven should manage that and only include one. So far, it all looks like expected behavior and you're trying to fix a problem that is not really a problem. – Gimby Jan 28 '14 at 12:44
  • 1
    Try `mvn dependency:tree -Dverbose` to get more info on whether it is actually included or not. – Keppil Jan 28 '14 at 12:52

2 Answers2

0

The spring-context pom defines the dependency to spring-core with exact the same version as the spring-context.

<dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-core</artifactId>
    <version>${project.version}</version>
    <scope>compile</scope>
</dependency>

Thus you must have a dependencyManagement somewhere in your project that tells maven to use 3.0.5.RELEASE instead of 3.1.1.RELEASE.

Take a look at your poms. There must be something like this in a dependencyManagement.

<dependencyManagement>
    <dependency>
       <groupId>org.springframework</groupId>
       <artifactId>spring-core</artifactId>
        <version>3.0.5.RELEASE</version>
    </dependency>
</dependencyManagement>

Depending on your maven version it might also be possible that you use dependency import.

PS: same for spring-asm

René Link
  • 48,224
  • 13
  • 108
  • 140
0

If i add only the org.springframework:spring-web:jar:3.1.1.RELEASE to a project and show the tree via mvn dependency:tree the following output appears:

[INFO] \- org.springframework:spring-web:jar:3.1.1.RELEASE:compile
[INFO]    +- aopalliance:aopalliance:jar:1.0:compile
[INFO]    +- org.springframework:spring-beans:jar:3.1.1.RELEASE:compile
[INFO]    +- org.springframework:spring-context:jar:3.1.1.RELEASE:compile
[INFO]    |  +- org.springframework:spring-aop:jar:3.1.1.RELEASE:compile
[INFO]    |  +- org.springframework:spring-expression:jar:3.1.1.RELEASE:compile
[INFO]    |  \- org.springframework:spring-asm:jar:3.1.1.RELEASE:compile
[INFO]    \- org.springframework:spring-core:jar:3.1.1.RELEASE:compile
[INFO]       \- commons-logging:commons-logging:jar:1.1.1:compile

wher never got a reference to org.springframework:spring-core:jar:3.0.5.RELEASE or org.springframework:spring-asm:jar:3.0.5.RELEASE. This means you have an other dependency which introduces that or you are using a dependencyManagement block overwrites that.

khmarbaise
  • 92,914
  • 28
  • 189
  • 235