views:

51

answers:

1

I'm a beginner with maven 2 and I have a problem with the version of a jar in my project. I have the following dependency declared in my pom.xml:

<dependency>
  <groupId>commons-logging</groupId>
  <artifactId>commons-logging</artifactId>
  <version>1.1.1</version>
</dependency>

But when I build my war, I get version 1.0.3 of that artifact. How is that possible!? On top of that, version 1.1.1 is available in my repository.

How to see from where it comes from?

I'm the new maintainer of this project. The parent pom declares this version, the war's pom inherits from the parent's pom.

+1  A: 

But in my war I find the version 1.0.3. How is that possible? (...) How to see where it comes from?

You are very likely getting this dependency transitively (i.e. you have a dependency on an artifact that has commons-logging-1.0.3.jar as dependency and you get it from this artifact). To check from where it comes from, you can print the "dependency tree" using the Maven Dependency Plugin (can also find conflicts):

mvn dependency:tree

Now, to solve the problem and control the versions used in transitive dependencies, the solution would be to declare your dependency under the dependencyManagement element:

<dependencyManagement>
  <dependencies>
    <dependency>
      <groupId>commons-logging</groupId>
      <artifactId>commons-logging</artifactId>
      <version>1.1.1</version>
    </dependency>
  </dependencies>
</dependencyManagement>
Pascal Thivent