pom.xml报错web.xml is missing and <failOnMissingWebXml> 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>

 

posted @ 2019-06-18 22:44  苏子榆  阅读(37083)  评论(1编辑  收藏  举报