Failed to execute goal org.apache.maven.plugins:maven-war-plugin 解決辦法
阿新 • • 發佈:2019-02-02
使用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>