下面记录在工作中遇到的maven打war遇到的问题
在使用maven打war包的时候可能遇到Failed to execute goal org.apache.maven.plugins:maven-war-plugin:2.1.1:war (default-war) on project web_nanchang: Error assembling WAR: webxml attribute is required
原因在于找不到web.xml这个配置文件了。我们在pom.xml中配置插件
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.3</version>
<configuration>
<webResources>
<resource>
<directory>src/main/webapp</directory>
</resource>
</webResources>
</configuration>
</plugin>
directory标签中的值就是你webappname下的路径,可以定位到web.xml。
如果你的项目中根本没有web.xml在pom.xml中直接如下配置即可
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.3</version>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>
</plugins>