pom.xml出现web.xml is missing and <failOnMissingWebXml> is set to true解决方案
提示信息应该能看懂。也就是缺少了web.xml文件,<failOnMissingWebXml>被设置成true了。
搜索了一下,Stack Overflow上的答案解决了问题,分享一下。
目前被顶次数最多的回答原文如下:
This is a maven error. It says that it is expecting a web.xml file in your project because it is a web application, as indicated by <packaging>war</packaging>
. However, for recent web applications a web.xml file is totally optional. Maven needs to catch up to this convention. Add this to your maven pom.xml
to let maven catch up and you don't need to add a useless web.xml
to your project:
大意是说这是一个Maven错误,在最近的web应用开发中web.xml文件已经变得可有可无了。不过Maven还没有跟上这一变化,我们只要在pom.xml文件中手动添加如下配置:
<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>
“告知”maven即可。这样做的好处是我们不必在项目生中成一个无用的web.xml文件。在更新版本(具体从哪一个版本开始我也不知道~~)的maven中已经不存在web.xml文件缺失的问题,我们只需要处理<failOnMissingWebXml>被设置成tue的问题即可。也就是在pom.xml中添加如下配置即可。
<properties>
<failOnMissingWebXml>false</failOnMissingWebXml>
</properties>
其他方案:(生成web.xml——>部署运行时文件路径)
you can do it also like this:
- Right click on Deployment Descriptor in Project Explorer.
- Select Generate Deployment Descriptor Stub.
It will generate WEB-INF folder in src/main/webapp and an web.xml in it.
这是被采纳方案,也就是说在项目浏览器中右键单击Deloyment Descriptor,选择生成部署描述符存根:Generate Deployment Descriptor Stub。
操作后会在项目的src/main/webapp/WEB-INF目录下生成web.xml文件。我按照这个方法生成了web.xml文件,但是仍然报错。如果你也是的话可以接着往下看。
Here are the steps you can follow:
- You can check this by right clicking your project, and open its Properties dialogue, and then "Deployment Assembly", where you can add Folder /src/main/webapp. Save the setting, and then,
- Go to Eclipse menu Project -> Clean... and clean the project, and the error should go away.
此时需要对src/main/webapp文件进行运行时的路径部署,以保证服务器正常运行。
也就是说需要部署一下src/main/webapp(刚生成的web.xml就在该文件夹下)文件夹,Deployment的作用是会在运行时将相应的resource复制到web服务器的相应目录下(通过Deploy Path指定),保证web应用正常运行。
经过这两步,问题解决。
pom.xml出现web.xml is missing and <failOnMissingWebXml> is set to true解决方案的更多相关文章
- 【maven】maven创建web项目-pom文件提示web.xml is missing and <failOnMissingWebXml> is set to true
使用maven创建web项目,选择war类型后,pom文件红叉 提示web.xml is missing and <failOnMissingWebXml> is set to true ...
- pom.xml中web.xml is missing and <failOnMissingWebXml> is set to true错误的解决
.personSunflowerP { background: rgba(51, 153, 0, 0.66); border-bottom: 1px solid rgba(0, 102, 0, 1); ...
- 解决Eclipse里的Maven工程pom.xml文件报:web.xml is missing and <failOnMissingWebXml> is set to true错误
打开eclipse准备进行开发时,发现项目上有个红星号,查看错误后发现报了一个:"web.xml is missing and <failOnMissingWebXml> is ...
- maven的pom报错web.xml is missing and <failOnMissingWebXml> is set to true
错误信息:web.xml is missing and <failOnMissingWebXml> is set to true 解决办法:https://blog.csdn.net/si ...
- 创建Maven web项目时 出现 web.xml is missing and <failOnMissingWebXml> is set to true错误 pox.xml编译错误
今天创建一个maven项目 pom.xml出现如下错误: web.xml is missing and <failOnMissingWebXml> is set to true 这是因为你 ...
- 解决 web.xml is missing and <failOnMissingWebXml> is set to true 报错
在学习maven模块化构建项目的时候遇到了如下报错信息: web.xml is missing and <failOnMissingWebXml> is set to true. 这时候需 ...
- Eclispe创建maven工程缺失web.xml报web.xml is missing and <failOnMissingWebXml> is set to true的错误
Eclispe创建maven工程缺失web.xml报web.xml is missing and <failOnMissingWebXml> is set to true的错误,一看,还缺 ...
- 解决maven项目中web.xml is missing and <failOnMissingWebXml> is set to true
web.xml is missing and <failOnMissingWebXml> is set to true 是因为项目中没有web.xml文件, 步骤如下:
- 新建Maven工程,pom.xml报错web.xml is missing and <failOnMissingWebXml> is set to true
错误原因: 项目中没有web.xml 解决办法: 在项目中添加web.xml 在pom.xml中添加下面的插件 <build> <plugins> <plugin> ...
随机推荐
- .net core2.0 中使用DB First
一.新建一个控制台测试项目 1.1.添加引用 1.2.修改项目文件 1.3.添加红框的内容 <ItemGroup> <DotNetCliToolReference Include=& ...
- “发布后tomcat中的classes目录为空”问题
办法:Project-clean,ok,问题解决.
- 英语之ASIC
ASIC(Application Specific Integrated Circuit) = 专用集成电路 assign = [计][数] 赋值 assign a value 分配一个值:赋值
- openMSP430之openmsp430-loader
openmsp430-loader This simple program allows the user to load the openMSP430 program memory with an ...
- MSP430之section(1)
1 Intro The smallest unit of an object file is a section. A section is a block of code or data that ...
- 彻底去除Google AdMob广告
应用中包含广告是能够理解的,但经常造成用户误点,或者广告切换时造成下载流量,就有点让人不舒服了. 以下就以Google AdMob广告为例,看怎样彻底去除他. 先分析一下Google AdMob的工作 ...
- C# 检测dll的新版本号方法
FileVersionInfo info = FileVersionInfo.GetVersionInfo(YourFileNameHere);string version = info.FileMa ...
- Mac下php连接mysql数据库失败解决办法
通过phpmyadmin连接mysql成功,但是通过php连接数据库失败,执行如下php语句 ? 1 @mysql_connect("localhost","root&q ...
- Maven常见异常及解决方法
异常1: [ERROR] Failed to execute goal on project biz_zhuhai: Could not resolve dependencies for projec ...
- webpack学习(二)
时下很火的react项目多用到webpack+ES6,本文只实践webpack的打包功能,不涉及react. 1.新建项目 新建的项目,命令模式下切换到项目根路径,用npm init命令生成packa ...