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>
即可
分类:
IntelliJ&Java环境相关
, Java
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】凌霞软件回馈社区,博客园 & 1Panel & Halo 联合会员上线
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】博客园社区专享云产品让利特惠,阿里云新客6.5折上折
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· PowerShell开发游戏 · 打蜜蜂
· 在鹅厂做java开发是什么体验
· 百万级群聊的设计实践
· WPF到Web的无缝过渡:英雄联盟客户端的OpenSilver迁移实战
· 永远不要相信用户的输入:从 SQL 注入攻防看输入验证的重要性
2021-06-15 Excel:获取等差时间