提示信息應該能看懂。也就是缺乏了web.xml文件,<failOnMissingWebXml>被設置成true了。web
搜索了一下,Stack Overflow上的答案解決了問題,分享一下。apache
目前被頂次數最多的回答原文以下:瀏覽器
This is a maven error. It says that it is expecting a web.xml file in your project because it is a web application, as indicated by <packaging>war</packaging>
. However, for recent web applications a web.xml file is totally optional. Maven needs to catch up to this convention. Add this to your maven pom.xml
to let maven catch up and you don't need to add a useless web.xml
to your project:服務器
大意是說這是一個Maven錯誤,在最近的web應用開發中web.xml文件已經變得無關緊要了。不過Maven尚未跟上這一變化,咱們只要在pom.xml文件中手動添加以下配置:app
<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>
「告知」maven便可。這樣作的好處是咱們沒必要在項目生中成一個無用的web.xml文件。在更新版本(具體從哪個版本開始我也不知道~~)的maven中已經不存在web.xml文件缺失的問題,咱們只須要處理<failOnMissingWebXml>被設置成tue的問題便可。也就是在pom.xml中添加以下配置便可。less
<properties> <failOnMissingWebXml>false</failOnMissingWebXml> </properties>
其餘方案:(生成web.xml——>部署運行時文件路徑)webapp
you can do it also like this:maven
It will generate WEB-INF folder in src/main/webapp and an web.xml in it.ui
這是被採納方案,也就是說在項目瀏覽器中右鍵單擊Deloyment Descriptor,選擇生成部署描述符存根:Generate Deployment Descriptor Stub。this
操做後會在項目的src/main/webapp/WEB-INF目錄下生成web.xml文件。我按照這個方法生成了web.xml文件,可是仍然報錯。若是你也是的話能夠接着往下看。
Here are the steps you can follow:
此時須要對src/main/webapp文件進行運行時的路徑部署,以保證服務器正常運行。
也就是說須要部署一下src/main/webapp(剛生成的web.xml就在該文件夾下)文件夾,Deployment的做用是會在運行時將相應的resource複製到web服務器的相應目錄下(經過Deploy Path指定),保證web應用正常運行。
通過這兩步,問題解決。