创建Maven web项目时 出现 web.xml is missing and <failOnMissingWebXml> is set to true错误 pox.xml编译错误

今天创建一个maven项目 pom.xml出现如下错误:

 web.xml is missing and <failOnMissingWebXml> is set to true

这是因为你因为你WEB-INF下没有web.xml导致造成的

解决方案:

右击项目——>Java EE Tools——>Generate Deployment Descriptor Stub.然后系统会在src/main/webapp/WEB_INF文件加下创建web.xml文件。错误解决!

当然这个方法是针对web项目的解决方案,如果你的工程不是web项目,那么还有另外一种解决方案,就是在pom文件中配置一下failOnMissingWebXml。具体配置如下:

 1 <build>
 2  
 3   <plugins>
 4  
 5    <plugin>
 6  
 7     <groupId>org.apache.maven.plugins</groupId>
 8  
 9     <artifactId>maven-war-plugin</artifactId>
10  
11     <version>2.6</version>
12  
13     <configuration>
14  
15      <failOnMissingWebXml>false</failOnMissingWebXml>
16  
17     </configuration>
18  
19    </plugin>
20  
21   </plugins>
22  
23  </build>

猜你喜欢

转载自www.cnblogs.com/coder-wf/p/12221942.html