2

I know i probably put together different versions which don't work together but i don;t know how to figure out where. I'm new to maven and spring and this is a common problem i have so can you tell me what's wrong here and how to recognize on the future incompatible versions ? Here is my pom.xml:

<dependencies>
    <dependency>
        <groupId>aopalliance</groupId>
        <artifactId>aopalliance</artifactId>
        <version>1.0</version>
    </dependency>
    <dependency>
        <groupId>org.aspectj</groupId>
        <artifactId>aspectjweaver</artifactId>
        <version>1.8.6</version>
    </dependency>
    <dependency>
        <groupId>org.gatein.common</groupId>
        <artifactId>common-logging</artifactId>
        <version>2.2.2.Final</version>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-aop</artifactId>
        <version>4.2.0.RELEASE</version>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-asm</artifactId>
        <version>3.1.4.RELEASE</version>
    </dependency>
    <dependency>
        <groupId>servletapi</groupId>
        <artifactId>servlet-api</artifactId>
        <version>2.4-20040521</version>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-beans</artifactId>
        <version>4.2.0.RELEASE</version>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-context</artifactId>
        <version>4.2.0.RELEASE</version>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-core</artifactId>
        <version>4.2.0.RELEASE</version>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-expression</artifactId>
        <version>4.2.0.RELEASE</version>
    </dependency>
    <dependency>
        <groupId>springframework</groupId>
        <artifactId>spring-jdbc</artifactId>
        <version>1.2.6</version>
    </dependency>
    <dependency>
        <groupId>org.springframework.security</groupId>
        <artifactId>spring-security-config</artifactId>
        <version>4.0.2.RELEASE</version>
    </dependency>
    <dependency>
        <groupId>org.springframework.security</groupId>
        <artifactId>spring-security-core</artifactId>
        <version>4.0.2.RELEASE</version>
    </dependency>
    <dependency>
        <groupId>org.springframework.security</groupId>
        <artifactId>spring-security-web</artifactId>
        <version>4.0.2.RELEASE</version>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-web</artifactId>
        <version>4.2.0.RELEASE</version>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-webmvc</artifactId>
        <version>4.2.0.RELEASE</version>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-tx</artifactId>
        <version>4.2.0.RELEASE</version>
    </dependency>
</dependencies>

I follow different tutorials while creating projects and because they are older I always face the dependency problem http://www.studytrails.com/frameworks/spring/spring-security-using-xml.jsp

Danielson
  • 2,605
  • 2
  • 28
  • 51
dskfdskjgds
  • 341
  • 3
  • 14

1 Answers1

1

First try to create the property values as such (in pom.xml):

<properties>
    <spring.version>4.2.0.RELEASE</spring.version>
</properties>
<!-- both properties as dependencies are directly under `project`!, don't use 
`dependencyManagement` until later -->
<dependencies>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-beans</artifactId>
        <version>${spring.version}</version>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-aop</artifactId>
        <version>${spring.version}</version>
    </dependency>
</dependencies>

which makes it easier to update all at the same time.
To see whether different dependencies are used, open the pom.xml (in Eclipse)
Click on the Dependency Hierarchy tab (bottom)
Here you can see whether there are conflicts between dependencies, and how they are related with your code and the hierarchy of directly or indirectly imported dependencies.

Also what helps, is to check whether you've imported the last versions, by calling (see https://stackoverflow.com/a/2687228/928952 for an example)

mvn versions:display-dependency-updates

One more thing, wrt versions (see version update policy):

7.1 How Version Numbers Work in Maven Maven's versioning scheme uses the following standards:

MajorVersion
MinorVersion
IncrementalVersion
BuildNumber
Qualifier For

example:

MajorVersion: 1.2.1
MinorVersion: 2.0
IncrementalVersion: 1.2-SNAPSHOT
BuildNumber: 1.4.2-12
Qualifier: 1.2-beta-2

Community
  • 1
  • 1
Danielson
  • 2,605
  • 2
  • 28
  • 51
  • ok. the property thing seems a good practice but i changed it in the spring-asm dependency and tells me it can't find the 4.2.0 version for it. And i'm not sure i understand the hierarchies i see there – dskfdskjgds Aug 13 '15 at 07:23
  • Be aware, not all the Spring versions are updated equally, like Security is always (around) a full version behind, Asm (see http://mvnrepository.com/artifact/org.springframework/spring-asm) also appears to be `3.1.4.RELEASE` as the latest... If you have a problem like the one you have now, check `http://mvnrepository.com/` and search for the dependency. There you'll find the last version – Danielson Aug 13 '15 at 07:26
  • The `Dependency Hierarchy` can be somewhat overwhelming, especially when using `spring-framework` because it uses a lot of external sources. What you are especially looking for (I think), is when you see (in the left screen in particular) `[version conflict, omitting version]' (something like that) – Danielson Aug 13 '15 at 07:28