Maven打包install项目报错Failed to execute goal org.apache.maven.plugins:maven-war-plugin:2.2:war (default-war) on project trawms-auth: Error assembling WAR: webxml attribute is required (or pre-existing WEB-INF/web.xml if executing in update mode),本人暂时发现两种方式,记录一下
1.一种是maven进行install,但项目中并没有本来就不需要web.xml文件,这种情况下在pom文件中添加配置:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.2</version>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>
2.第二种:Maven默认会去src\main\webapp下去找web.xml,而我们项目经常会改为WebRoot目录代替src\main\webapp目录,此时我们就需要自己重新配置一下web.xml路径
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.2</version>
<configuration>
<!-- 指定web.xml所在的路径 -->
<webXml>WebRoot\WEB-INF\web.xml</webXml>
<!-- 指定jsp、js、css的路径 -->
<warSourceDirectory>WebRoot</warSourceDirectory>
</configuration>
</plugin>
maven项目重新编译install应该就可以了