问题描述:有时候新建的maven工程后,项目的pom.xml中报错:web.xml is missing and <failOnMissingWebXml> is set to trueweb
如图:apache
解决分两种状况(三种解决方法):app
1.若项目中不须要web.xml文件,且不是Web工程,则直接在pom.xml文件中加入如下配置,而后update一下项目:webapp
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.6</version>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>
</plugins>
</build>
2.项目是Web工程,则须要web.xml文件(两种解决方案)maven
1)最简单最直接的是在src/main/webapp/下新建WEB-INF/web.xml(也能够从其余项目中拷贝一个web.xml过来),以下图。而后刷新项目:ui
2)最可靠的是让项目自动 WEB-INF/web.xml生成。操做步骤以下:spa
①右击项目,而后点击Properties-->Project Facets,将在右侧Dynamic Web Module选中项去除,再点击Apply(应用)。code
②而后从新勾选Dynamic Web Module,点击下方的Further configuration available... 在弹出的窗口中配置Content directory的值填入:src/main/webapp,点击ok ,再点击Appy --> Apply and Close.刷新工程便可。以下图:xml
③完成后,自动生成的结构以下图,很是完整:blog
若过程当中还有其余问题,欢迎留言一块儿解决。