Java:Failed to execute goal org.apache.maven.plugins:maven-war-plugin

可能有3个原因导致出现该问题:

1、项目中没有 src/main/webapp/WEB-INF/web.xml 文件;

2、有了上述文件,但是没在pom.xml中说明这个文件的位置;

3、以上两个都有,但是 pom.xml 中的插件maven-war-plugin版本不对

两种解决方法:

1、有web.xml文件的前提下,解决步骤(2022年6月版本):

①首先要保证有web.xml文件,且文件在src/main/web/WEB-INF目录下,有时可能会因为不小心把web和main放在同级目录下而出错;

 

②在pom.xml中说明WEB-INF的位置,写法如下:

复制代码
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-war-plugin</artifactId>
                <version>3.2.1</version>
                <configuration>
                    <webResources>
                        <resource>
                            <directory>src/main/webapp</directory>
                        </resource>
                    </webResources>
                </configuration>
            </plugin>
        </plugins>
    </build>
复制代码

③注意maven-war-plugin的版本,之前我用3.0.0版本就会报错,用3.2.1版本就不会报错

 

2、没有web.xml文件的前提下,解决步骤(2022年6月版本):

现在我们的文件结构下,没有web.xml文件了

 

 ①在pom.xml中说明插件maven-war-plugin

复制代码
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-war-plugin</artifactId>
                <version>3.2.1</version>
            </plugin>
        </plugins>
    </build>
复制代码

②在<properties>块中说明忽略了web.xml文件:

    <properties><failOnMissingWebXml>false</failOnMissingWebXml>
    </properties>

即可

 

posted @   ShineLe  阅读(1447)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· PowerShell开发游戏 · 打蜜蜂
· 在鹅厂做java开发是什么体验
· 百万级群聊的设计实践
· WPF到Web的无缝过渡:英雄联盟客户端的OpenSilver迁移实战
· 永远不要相信用户的输入:从 SQL 注入攻防看输入验证的重要性
历史上的今天:
2021-06-15 Excel:获取等差时间
点击右上角即可分享
微信分享提示