maven中出现web.xml is missing and <failOnMissingWebXml> is set to true的错误如何解决

来源:互联网 发布:linux查看重启日志 编辑:程序博客网 时间:2024/06/05 16:03

在建立一个new maven project 的时候,create simple成功简历一个maven项目的时候会出现一个错误; 

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

解决方法如下:

在src/main/webapp/下新建一个WEB-INF文件,并且在WEB-INF文件下建立一个web.xm;如图



web.xml内容如下:


<?xml version="1.0" encoding="UTF-8"?><web-app version="3.0" xmlns="http://java.sun.com/xml/ns/javaee"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"><display-name>Archetype Created Web Application</display-name></web-app>


但是仍然还是报这个错误,需要两步操作


1)右击项目,打开Properties对话框,点击Deployment Assembly选项,在右边添加一个文件夹,并且保存设置


    2)在eclispe上方点击Project ->Clean 清理一下这个项目;

方法二:

添加配置,放过该错误提示

[xml] view plain copy
  1. <build>  
  2.     <plugins>  
  3.         <plugin>  
  4.             <groupId>org.apache.maven.plugins</groupId>  
  5.             <artifactId>maven-war-plugin</artifactId>  
  6.             <version>2.3</version>  
  7.             <configuration>  
  8.                 <failOnMissingWebXml>false</failOnMissingWebXml>  
  9.             </configuration>  
  10.         </plugin>  
  11.     </plugins>  
  12. </build>  





阅读全文
0 0
原创粉丝点击