java 如何从我的 Maven 构建中排除资源,packagingExcludes 不起作用
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/16138959/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to exclude resources from my maven build, packagingExcludes not working
提问by Blankman
I am using the maven-war-pluginto build a .war file
我正在使用maven-war-plugin构建一个 .war 文件
I am using packagigExcludes and it is working fine for .jar files:
我正在使用 packagigExcludes 并且它适用于 .jar 文件:
<packagingExcludes>WEB-INF/lib/jetty-*.ja
WEB-INF/../resources/log4j.properties,
WEB-INF/../resources/web.properties
</packagingExcludes>
But the properties files above are not getting exluded, I also tried:
但是上面的属性文件没有被排除,我也试过:
src/main/resources/web.properties
This is a multi-module maven project, and I am building a .war file for this spring mvc maven project and I have to exclude these files but it isn't working.
这是一个多模块 maven 项目,我正在为这个 spring mvc maven 项目构建一个 .war 文件,我必须排除这些文件,但它不起作用。
Any pointers?
任何指针?
回答by rmalchow
i just tried ... are you sure you're doing the configuration in the right place? my pom looks like this:
我刚刚试过...你确定你在正确的地方进行配置吗?我的 pom 看起来像这样:
<?xml version="1.0"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.example</groupId>
<artifactId>example-parent</artifactId>
<version>0.1.4-SNAPSHOT</version>
</parent>
<artifactId>example-webapp</artifactId>
<packaging>war</packaging>
<url>http://maven.apache.org</url>
<dependencies>
[...]
</dependencies>
<build>
<plugins>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>2.3</version>
<configuration>
<packagingExcludes>WEB-INF/lib/*.jar</packagingExcludes>
</configuration>
</plugin>
</plugins>
<finalName>example-webapp</finalName>
</build>
</project>
----> EDIT
----> 编辑
to exlude stuff from resource, you would have to do this:
要从资源中排除内容,您必须这样做:
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>2.3</version>
<configuration>
<packagingExcludes>
WEB-INF/classes/log4j.properties
</packagingExcludes>
</configuration>
</plugin>
回答by Jigar Joshi
Add this in pom.xml
添加这个 pom.xml
</build>
<resources>
<resource>
<directory>src/main/resources</directory>
<excludes>
<exclude>web.properties</exclude>
</excludes
</resource>
</resources>
</build>