Good day to you, Sha Jiang,

Maven2 handles dependencies by searching for versionless artifact keys from
the dependency tree and chooses the version which is closest to the root (
the pom you ran your mvn command on ). Therefore, you cannot depend on two
different versions of an artifact. If you see a name-x.jar and a name-y.jar,
then that would most likely mean that they are of different groupIds (
either that or you failed to clean, or it was placed there by some other
plugin like maven-dependency-plugin, maven-assembly-plugin,
maven-antrun-plugin, etc).

Btw, the artifcat key is the name of the artifact in the following format -
<groupId>:<artifactId>:<version>. Thus, a versionless artifact key is of the
format, <groupId>:<artifactId>.

To trace your dependency tree, you can use mvn
project-info-reports:dependencies. This will then generate a dependency tree
report in your traget\site\dependencies.html. Furthermore, if you doubt the
information given by that report, you can add the -X option in your maven
command so that you can trace through the debug logs. 

Cheers,
Franz


jiangshachina wrote:
> 
> Hi,
> I have a Web project.
> I declare ehcache-1.2.3.jar as dependency.
> But ehcache-1.1.jar is transitive dependency of one of my directly
> dependency(acegi-security-1.0.2.jar).
> Then I run "mvn clean package", the two jar files are all in WEB-INF/lib.
> How to resolve the problem?
> 
> More strangely, I changed the POM of artifact acegi-security-1.0.2.jar,
> and made it to use ehcache-1.2.3.jar,
> But ehcache-1.1.jar still was in WEB-INF/lib.
> May ehcache-1.1.jar is other (direct or indirect) dependencies' transitive
> denpendency,
> but I can't find all.
> How to resolve the problem?
> 
> Thanks in advance.
> 
> a cup of Java, cheers!
> Sha Jiang
> 

-- 
View this message in context: 
http://www.nabble.com/adds-same-artifacts%28different-version%29--tf2729513s177.html#a7650831
Sent from the Maven - Users mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to