ChatGPT解决这个技术问题 Extra ChatGPT

Disable Maven warning message - "Selected war files include a WEB-INF/web.xml which will be ignored"

When building WAR package using Maven 2.1.1, I get this warning message:

[WARNING] Warning: selected war files include a WEB-INF/web.xml which will be ig
nored
(webxml attribute is missing from war task, or ignoreWebxml attribute is specifi
ed as 'true')

Is there a way to eliminate it? It doesn't fail the building process, but I just do not want to see it.


D
David Balažic

It seems to be fixed in current version of maven-war-plugin, so just specifying:

    <plugin>
        <artifactId>maven-war-plugin</artifactId>
        <version>2.3</version>
    </plugin>

fixed it for me. (See the last answer (20/Sep/12 4:37 AM) from Anders Hammar on https://issues.apache.org/jira/browse/MWAR-248.)


Agreed. As of version 2.3, they finally took care of this annoying warning message for OCD programmers like me :)
Yes, this fixed it, however somehow <webXml>src/main/webapp/WEB-INF/web.xml</webXml> didn't for me using version 2.1.1
V
Vitaly Olegovitch

I got rid of this warning in maven 3.0.1 with the following build configuration (i believe perhaps web.xml is added to the project by other means, and should't be packaged by default):

<project>
    ...
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-war-plugin</artifactId>
                <version>2.6</version>
                <configuration>
                    <packagingExcludes>WEB-INF/web.xml</packagingExcludes>
                </configuration>
            </plugin>
        </plugins>
    </build>
    ...
</project>

I found you can add this to the configuration to be sure web.xml makes it in. At this time it appears optional, but better safe than sorry. <webXml>src/main/webapp/WEB-INF/web.xml</webXml>
Including the project-relative path doesn't seem to work; however, the format in the answer does.
I'll try this. Within <configuration> I also have <warName>${package.final.name}</warName>. What does this do?
I had to use 2.2 or the war will contain a default web.xml instead of the one I specify. 2.1.1 worked for a while, but not anymore.
I am down-voting this response, because while it does get rid of the error warning, it is the wrong and confusing thing to do! You should do what shockwave described or if you are happy with the default web.xml then don't write one yourself at all.
D
David Balažic

I've filed the following bug report regarding this issue: https://issues.apache.org/jira/browse/MWAR-248


This bug is reported as closed but I get this message in maven 3.0.4 on windows 7. Even after adding src/main/webapp/WEB-INF/web.xml to my pom.xml
@simgineer, you should comment inside the bug report. If that doesn't help, consider opening a new bug report and linking to it from here.