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

版权声明:本文为博主原创文章,转载请注明出处。如有错误,欢迎大家批评指正。 https://blog.csdn.net/a_bang/article/details/72849483

使用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.plugins</groupId>
                <artifactId>maven-war-plugin</artifactId>
                <version>3.0.0</version>
                <configuration>
                    <webResources>
                        <resource>
                            <directory>WebContent</directory>
                        </resource>
                    </webResources>
                </configuration>
            </plugin>
        </plugins>
</build>

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

<build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-war-plugin</artifactId>
                <version>3.0.0</version>
                <configuration>
                    <failOnMissingWebXml>false</failOnMissingWebXml>
                </configuration>
            </plugin>
        </plugins>
</build>

猜你喜欢

转载自blog.csdn.net/a_bang/article/details/72849483
今日推荐