简体   繁体   English

如何使用Maven在WAR档案WEB-INF / lib中包含JAR?

[英]How to include JARs in WAR archive WEB-INF/lib using Maven?

My Maven pom file builds a war without the dependencies, so that i have to manually add them to the WEB-INF/lib. 我的Maven pom文件构建了一个没有依赖关系的war ,所以我必须手动将它们添加到WEB-INF / lib。

Is there any way to instruct Maven to include all the dependencies within the war ? 有没有办法指示Maven包含war所有依赖? So the the war become self content and independent 所以war变得自我内容和独立

Just make sure the type of your pom is war . 只要确保你的pom类型是war Maven's default behavior is to copy dependencies in the lib folder. Maven的默认行为是复制 lib文件夹中的依赖项。 PS If you found any trouble post your full pom. PS如果您发现完整的pom有任何问题。 Besides see maven war plugin for further doc 此外,请参阅maven war插件以获取更多文档

Yes, make sure the packaging is of type war like <packaging>war</packaging> . 是的,确保包装类型为<packaging>war</packaging> Also check if the dependencies in your pom are of the right scope, for example if they are not default or the compile scope, that's possibly why they are not bundled into the war's lib folder. 还要检查pom中的依赖项是否在正确的范围内,例如,如果它们不是默认值或编译范围,那么它们可能不会捆绑到war的lib文件夹中。

<dependency>
 ..
 ..
 <scope>compile</scope>
<dependency>

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

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