如果不是独立构建,Maven war 包含额外的依赖项
我有一场战争,我试图减少 WEB-INF/lib 中包含的依赖项,因为它们是由耳朵提供的,如果它们只在耳朵中,它可以解决我遇到的一些类加载器问题。
如果我在模块中运行 mvn clean install 进行战争,它只会构建我想要的依赖项。如果我提升一个级别并在项目上运行 mvn install(war 在该级别被定义为 pom.xml 中的模块),那么 war 将使用更多依赖项重新打包。
为什么行为会有所不同?如何阻止所有这些额外的依赖项进入?
我尝试遵循此处的建议,但发现行为没有任何区别: http://maven.apache.org/plugins/maven-war-plugin/examples/skinny-wars.html
Maven 2.0.6、maven-ear-plugin 2.4.1、maven-war-插件 2.1-beta-1(我无法更改版本,我位于封闭网络上)。提前致谢。
ETA:项目级别的 mvn clean 安装给了我想要的结果。 mvn clean 然后 mvn install 添加了我不想要的额外 jar。
I've got a war which I'm trying to reduce the dependencies contained in it's WEB-INF/lib as they're provided by the ear and if they're only in the ear it resolves some classloader issues I've had.
If I run mvn clean install in the module for the war it builds in only the dependencies I want. If I go up a level and run mvn install on the project (the war's defined as a module in the pom.xml at this level) then the war is repackaged with a lot more dependencies.
Why would the behaviour be different and how can I stop all these extra dependencies getting in?
I've tried following the advice here but saw no difference in the behaviour: http://maven.apache.org/plugins/maven-war-plugin/examples/skinny-wars.html
Maven 2.0.6, maven-ear-plugin 2.4.1, maven-war-plugin 2.1-beta-1 (I can't change the versions, I'm on a closed network). Thanks in advance.
ETA: A mvn clean install at the project level gives me the results I want. An mvn clean and then an mvn install adds in the extra jars that I don't want.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
运行 mvn dependency:tree 来查看(可能是传递性的)依赖项来自何处。
您需要阅读“Maven 权威指南”(Sonatype 提供的免费 PDF),以便深入了解 Maven 如何处理依赖关系管理。
请找到一种方法升级到maven 2.1.0(最好是2.2.1)和最新版本的插件,早期版本是出了名的错误。
Run
mvn dependency:tree
to see where the (probably transitive) dependencies are coming in from.You'll want to read "Maven the Definitive Guide" (free PDF by Sonatype) in order to get an in depth understanding of how Maven deals with Dependency management.
And please do find a way to upgrade to maven 2.1.0 (preferably 2.2.1), and the latest versions of the plugins, earlier versions are notoriously buggy.