简体   繁体   English

WEB-INF中具有相同groupId和artifactId的多个罐

[英]Multiple jars of same groupId and artifactId in WEB-INF

I am using maven version 3.5.3 and while building my project, I am getting two versions of apache commons-lang3 in my WEB-INF ( v3.1 and v3.4 ) even when I have explicitly specified v.3.4 in my " dependency-management " of my parent pom.xml. 我使用的是Maven版本3.5.3,并且在构建项目时,即使在我的““中明确指定了v.3.4,我的WEB-INF也获得了两个版本的apache commons-lang3v3.1和v3.4 )。我的父pom.xml的“ 依赖项管理 ”。

Both have the same groupId and artifactId. 两者具有相同的groupId和artifactId。

I am confused. 我很困惑。 Is this expected behavior of maven? 这是Maven的预期行为吗? Under what circumstances does this happen? 在什么情况下会发生这种情况? I was under the impression that maven resolves all dependencies to only one jar if dependencies have same groupId and artifactId. 我的印象是,如果依赖项具有相同的groupId和artifactId,则maven会将所有依赖项解析为一个jar。

I am confused. 我很困惑。 Is this expected behavior of maven? 这是Maven的预期行为吗? Under what circumstances does this happen? 在什么情况下会发生这种情况? I was under the impression that maven resolves all dependencies to only one jar if dependencies have same groupId and artifactId. 我的印象是,如果依赖项具有相同的groupId和artifactId,则maven会将所有依赖项解析为一个jar。

And Maven does. 而Maven做到了。
For a same groupId and a same artifactId, the default behavior of a Maven package goal is packaging only one version of them. 对于相同的groupId和相同的artifactId,Maven软件包目标的默认行为是仅打包它们的一个版本。 Note that if multiple versions are available, the chosen version by Maven is not really predictable. 请注意,如果有多个版本可用,则Maven选择的版本实际上是不可预测的。

I imagine that at a time your build performs a manual copy from the jar into the WEB-INF folder (via a Maven plugin for example), or your pom (or a parent of) specifies an overlay in the WAR . 我想像一下,您的构建会执行一次将jar手动复制到WEB-INF文件夹的操作(例如,通过Maven插件),或者您的pom(或其父级) 在WAR中指定了覆盖

The mvn dependency:tree command should help you to understand where the distinct versions are referenced or pulled. mvn dependency:tree命令应该可以帮助您了解引用或提取不同版本的位置。

I saw this problem several times when builds were done without "clean", ie using package instead of clean package . 在没有“ clean”的情况下完成构建时,我多次看到此问题,即使用package而不是clean package In this case, you may get a mixture of old and recent builds. 在这种情况下,您可能会混合使用旧版本和最新版本。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM