Maven項目pom.xml文件報錯「web.xml is missing and is set to true」

  解決方案引用自:web.xml is missing and <failOnMissingWebXml> is set to trueweb


  最近作的一個maven管理的web項目,遇到項目中pom.xml文件報「web.xml is missing and <failOnMissingWebXml> is set to   true」的錯誤,錯誤緣由是項目中沒有web.xml文件:
apache

wKioL1keUNuB1DzPAABNXDIX-uY271.png-wh_50

  經查詢找到3個解決方案:app

一、生成 web.xml 文件(若是確實不須要web.xml文件,建議跳過此方案,以保持項目代碼的乾淨)webapp

  • 在 Project Explorer 視圖窗口右擊項目的「Deployment Descriptor」項;maven

  • 選擇「Generate Deployment Descriptor Stub」;ide

  • 而後就在「src/main/webapp/WEB-INF」目錄下建立web.xml文件ui

wKiom1keVT6AQNYcAABotpxeqPw250.png-wh_50

二、在 pom.xml 文件中加入以下配置:
spa

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

三、在 pom.xml 文件中加入以下配置(短配置,與版本無關):
orm

<properties>
    <failOnMissingWebXml>false</failOnMissingWebXml>
</properties>
相關文章
相關標籤/搜索