从 webapp/WEB-INF/lib 中排除所有 jar
我的 WEB 项目中的第三方 jar 放置在 /src/main/webapp/WEB-INF/lib/
我已经提到了所有必需 JAR 的依赖关系pom.xml。 现在,由于依赖项是在 POM 中定义的,因此 JAR 将自动打包到 lib
文件夹中。
- 我想排除
lib
中的所有 JAR。 - 构建 WAR 时,应将依赖项 JAR 打包在 lib 内
我无法从 WEB-INF 中删除 LIB
因为它用于本地开发
这是我尝试过的远:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<configuration>
<packagingExcludes>META-INF/context.xml</packagingExcludes>
<webResources>
<resource>
<directory>src/main/webapp/WEB-INF/lib</directory>
<excludes>
<exclude>**/**</exclude>
</excludes>
</resource>
</webResources>
</configuration>
</plugin>
有什么想法吗?
I have the third party jar's in my WEB project placed at /src/main/webapp/WEB-INF/lib/
I have mentioned the dependency for all the required JAR's in the pom.xml.
Now, Since the dependencies are defined in POM, the JAR's will be automatically packed in the lib
folder.
- I want to exclude all the JAR's in the
lib
. - The Dependency JAR's should be packaged inside the lib while building the WAR
I CANT DELETE THE LIB
FROM WEB-INF BECAUSE ITS USED IN LOCAL DEVELOPMENT
This is what I've tried so far:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<configuration>
<packagingExcludes>META-INF/context.xml</packagingExcludes>
<webResources>
<resource>
<directory>src/main/webapp/WEB-INF/lib</directory>
<excludes>
<exclude>**/**</exclude>
</excludes>
</resource>
</webResources>
</configuration>
</plugin>
Any Idea?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
它应该是“packagingExcludes”而不是“warSourceExcludes”:
来自 http://maven.apache.org/plugins/maven-war-plugin/examples/skinny-wars.html:
It should be "packagingExcludes" instead of "warSourceExcludes":
From http://maven.apache.org/plugins/maven-war-plugin/examples/skinny-wars.html :
尝试一下:
但是,我确实同意 Jarrod 的观点,即“手动”将 jar 存储在
WEB-INF/lib
中是不好的做法。我之前使用过这个来避免 jars 作为依赖项被打包以便之后能够重新打包。Try this:
However, I do agree with Jarrod that it is bad practice to store your jars in
WEB-INF/lib
'manually'. I used this before to avoid that jars coming as a dependency got packaged to be able to repackage it afterwards.首先,您的
WEB-INF/lib
目录中不应该有任何内容。如果您使用 Eclipse,您可以告诉它从 pom.xml 构建项目,它会知道在 ~/.m2/repository 中查找依赖项、Intellij IDEA 也这样做。将依赖项放入 WEB-INF/lib 有点违背了使用 Maven 进行依赖项管理的目的。当pom.xml
中的依赖项与WEB-INF/lib
中的依赖项版本不同步时会发生什么you shouldn't have anything in your
WEB-INF/lib
directory to begin with. If you are using Eclipse, you can tell it to build its project from thepom.xml
and it will know to look in~/.m2/repository
for dependencies, Intellij IDEA does this as well. Putting dependencies inWEB-INF/lib
kind of defeats the purpose of using Maven for dependency management. What happens when the dependencies in thepom.xml
get out of sync version wise with those inWEB-INF/lib