Maven打包時報Failed to execute goal org.apache.maven.plugins:maven-war-plugin:2.2:war解決方案

問題現象:web

用Maven打包時,報Failed to execute goal org.apache.maven.plugins:maven-war-plugin:2.2:war錯誤。apache

 

緣由分析:maven

打包時在WebContent/WEB-INF/文件夾下找不到web.xml文件。ui

 

解決方案:spa

若是WebContent/WEB-INF/web.xml文件存在,須要在pom.xml文件的<build>節點中,加上maven-war-plugin插件配置。插件

 1 <plugins>
 2     <plugin>
 3         <groupId>org.apache.maven.plugins</groupId>
 4         <artifactId>maven-war-plugin</artifactId>
 5         <version>3.0.0</version>
 6         <configuration>
 7             <webResources>
 8                 <resource>
 9                     <directory>WebContent</directory>
10                 </resource>
11             </webResources>
12         </configuration>
13     </plugin>
14 </plugins>

 

若是WebContent/WEB-INF/web.xml文件不存在,則按下面的方式配置。code

 1 <plugins>
 2     <plugin>
 3         <groupId>org.apache.maven.plugins</groupId>
 4         <artifactId>maven-war-plugin</artifactId>
 5         <version>3.0.0</version>
 6         <configuration>
 7             <failOnMissingWebXml>false</failOnMissingWebXml>
 8         </configuration>
 9     </plugin>
10 </plugins>
相關文章
相關標籤/搜索