如何从我的maven构建中排除资源,packagingExcludes不工作

Bla*_*man 5 java spring spring-mvc maven

我正在使用maven-war-plugin来构建.war文件

我正在使用packagigExcludes,它适用于.jar文件:

 <packagingExcludes>WEB-INF/lib/jetty-*.ja                        
                        WEB-INF/../resources/log4j.properties,
                        WEB-INF/../resources/web.properties
                    </packagingExcludes>
Run Code Online (Sandbox Code Playgroud)

但上面的属性文件没有被排除在外,我也尝试过:

src/main/resources/web.properties
Run Code Online (Sandbox Code Playgroud)

这是一个多模块maven项目,我正在为这个spring mvc maven项目构建一个.war文件,我必须排除这些文件,但它不起作用.

有什么指针吗?

rma*_*how 9

我刚试过......你确定你在正确的位置进行配置吗?我的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>
Run Code Online (Sandbox Code Playgroud)

---->编辑

要从资源中排除内容,您必须这样做:

            <plugin>
                <artifactId>maven-war-plugin</artifactId>
                <version>2.3</version>
                <configuration>
                    <packagingExcludes>
                        WEB-INF/classes/log4j.properties
                    </packagingExcludes>
                </configuration>
            </plugin>
Run Code Online (Sandbox Code Playgroud)