Maven and jar version in final artifact
I am starting with maven 2 and I have a jar version problem in my project. I have the following dependency declared in mine 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 this artifact. How is this possible !? Also, version 1.1.1 is available in my repository.
How do you know where it came from?
I am the new developer of this project. The parent pom declares this version, the war pom inherits from the parent pom.
a source to share
But in my war I found version 1.0.3. How is this possible? (...) How do you know where it came from?
You will probably end up with a transitive dependency (i.e. you have a dependency on an artifact that has commons-logging-1.0.3.jar as a dependency, and you get it from that artifact). To check where it came 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 in dependencyManagement
:
<dependencyManagement>
<dependencies>
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
<version>1.1.1</version>
</dependency>
</dependencies>
</dependencyManagement>
a source to share