1. 程式人生 > >解決 web.xml is missing and <failOnMissingWebXml> is set to true 報錯

解決 web.xml is missing and <failOnMissingWebXml> is set to true 報錯

今天在新建一個maven工程時遇到一個pom.xml檔案的報錯資訊:

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

 

解決方案1:

勾選專案右鍵點選——>Java EE Tools——>Generate Deployment Descriptor Stub.然後系統會在src/main/webapp/WEB_INF檔案加下建立web.xml檔案。

 

當然這個方法是針對web專案的解決方案。

如果你的工程不是web專案,那麼還有另外一種解決方案,就是在pom檔案中配置一下failOnMissingWebXml。具體配置如下:

<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>