mvn package一个web项目时,报错如下:Error assembling WAR:webxml attribute is required
原因:
maven的web项目默认的webroot是在src\main\webapp。如果在此目录下找不到web.xml就抛出以上的异常。
解决办法:需要在pom.xml中增加<webResources>配置,如下:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.4</version>
<configuration>
<webXml>webapps\WEB-INF\web.xml</webXml>
</configuration>
</plugin> 或者把webapps改成默认的webapp
本文介绍了在使用Maven打包Web项目时遇到的错误:“Error assembling WAR: webxml attribute is required”。该错误的原因在于Maven未能找到默认位置的web.xml文件。文章提供了两种解决方案:一是通过修改pom.xml文件指定web.xml的位置;二是将web.xml放置于默认路径src/main/webapp下。
3843

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



