Failed to execute goal org.apache.maven.plugins:maven-war-plugin 解决办法

使用maven打包时,报错误信息:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-war-plugin:2.2:war (default-war) on project provider: Error assembling WAR: webxml attribute is required (or pre-existing WEB-INF/web.xml if executing in update mode) -> [Help 1]

提示缺少web.xml

解决办法:

如果WebContent/WEB-INF/web.xml文件存在,需要在pom.xml文件中加上maven-war-plugin插件

<build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.pluginsgroupId>
                <artifactId>maven-war-pluginartifactId>
                <version>3.0.0version>
                <configuration>
                    <webResources>
                        <resource>
                            <directory>WebContentdirectory>
                        resource>
                    webResources>
                configuration>
            plugin>
        plugins>
build>

  
如果web.xml文件不存在,则按下面的方式配置。

<build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.pluginsgroupId>
                <artifactId>maven-war-pluginartifactId>
                <version>3.0.0version>
                <configuration>
                    <failOnMissingWebXml>falsefailOnMissingWebXml>
                configuration>
            plugin>
        plugins>
build>

你可能感兴趣的:(Maven)