maven-install报错:
- [ERROR] Failed to execute goal org.apache.maven.plugins:maven-war-plugin:2.1.1:war
- (default-war) on project com.alpha.webapp: Error assembling WAR:webxml attribute is required (or pre-existing WEB-INF/web.xml if executing in update
原因:
maven的web项目默认的webroot是在src\main\webapp。如果在此目录下找不到web.xml就抛出以上的异常。
解决办法:需要在pom.xml中的增加<webResources>配置,如下:
<build>
<plugins>
<!-- 配置web.xml的路径,maven的web项目默认的webroot是在src\main\webapp -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.2</version>
<configuration>
<webXml>webapp\WEB-INF\web.xml</webXml>
</configuration>
</plugin>
</plugins>
</build>
Maven WAR 插件配置
本文介绍了解决 Maven 在构建 WAR 包时因找不到 web.xml 文件而报错的方法。通过在 pom.xml 中指定正确的 web.xml 路径,可以避免此错误。
3806

被折叠的 条评论
为什么被折叠?



