pom.xml報錯web.xml is missing and is set to true 解決方案

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

  原因是在項目中缺少web.xml,且<failOnMissingWebXml>被設置成了true

  解決方法:a.如果項目需要web.xml,去複製一個web.xml到項目中即可。

          也可以使用Eclipse生成:有如下兩種方式

                    1.右擊項目——>Java EE Tools——>Generate Deployment Descriptor Stub.然後系統會在src/main/webapp/WEB_INF文件加下創建web.xml文件。錯誤解決!

          2.右擊項目——>Properties——>Project Facets  將Dynamic Web Module的勾去掉,點擊Apply,再重新勾上,點擊下方出現的Further configuration availber,再選擇生成的目錄即可生成web.xml

        

         

 

      b.如果項目不需要web.xml,則需要在pom.xml中將<failOnMissingWebXml>配置成false,有如下兩種配置方式

      1.

 

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

<properties>
    <failOnMissingWebXml>false</failOnMissingWebXml>
</properties>
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章