WEB-INF中具有相同groupId和artifactId的多个罐 [英] Multiple jars of same groupId and artifactId in WEB-INF

查看:140
本文介绍了WEB-INF中具有相同groupId和artifactId的多个罐的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Maven版本3.5.3,并且在构建项目时,我在WEB-INF中获得了两个版本的 apache commons-lang3 v3.1和v3.4 ),即使我在父pom.xml的 依赖性管理中明确指定了v.3.4。

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.

两者具有相同的groupId和artifactId。

Both have the same groupId and artifactId.

我很困惑。这是Maven的预期行为吗?在什么情况下会发生这种情况?我的印象是,如果依赖项具有相同的groupId和artifactId,则maven会将所有依赖项解析为一个jar。

I am confused. Is this expected behavior of 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.

推荐答案


我很困惑。这是Maven的预期行为吗?在什么
情况下会发生这种情况?我的印象是,如果依赖项具有相同的
groupId和artifactId,则maven
会将所有依赖项解析为一个jar。

I am confused. Is this expected behavior of 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.

Maven可以。

对于相同的groupId和相同的artifactId,Maven软件包目标的默认行为是仅打包它们的一个版本。请注意,如果有多个版本可用,则Maven选择的版本实际上是不可预测的。

And Maven does.
For a same groupId and a same artifactId, the default behavior of a Maven package goal is packaging only one version of them. Note that if multiple versions are available, the chosen version by Maven is not really predictable.

我想像一下,您的构建会执行一次将jar手动复制到WEB-INF文件夹(例如,通过Maven插件)或pom(或的父级)指定 WAR中的重叠

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.

mvn依赖项:tree 命令应该可以帮助您了解引用或提取不同版本的位置。

The mvn dependency:tree command should help you to understand where the distinct versions are referenced or pulled.

这篇关于WEB-INF中具有相同groupId和artifactId的多个罐的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆