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>

    原文作者:Clark_17_
    原文地址: https://www.jianshu.com/p/6b55c50431b9
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞