提示信息应该能看懂。也就是缺少了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:

  1. Right click on Deployment Descriptor in Project Explorer.
  2. 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:

  1. 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,
  2. 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解决方案的更多相关文章

  1. 【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 ...

  2. 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); ...

  3. 解决Eclipse里的Maven工程pom.xml文件报:web.xml is missing and <failOnMissingWebXml> is set to true错误

    打开eclipse准备进行开发时,发现项目上有个红星号,查看错误后发现报了一个:"web.xml is missing and <failOnMissingWebXml> is ...

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

  5. 创建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 这是因为你 ...

  6. 解决 web.xml is missing and <failOnMissingWebXml> is set to true 报错

    在学习maven模块化构建项目的时候遇到了如下报错信息: web.xml is missing and <failOnMissingWebXml> is set to true. 这时候需 ...

  7. 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的错误,一看,还缺 ...

  8. 解决maven项目中web.xml is missing and <failOnMissingWebXml> is set to true

    web.xml is missing and <failOnMissingWebXml> is set to true 是因为项目中没有web.xml文件, 步骤如下:

  9. 新建Maven工程,pom.xml报错web.xml is missing and <failOnMissingWebXml> is set to true

    错误原因: 项目中没有web.xml 解决办法: 在项目中添加web.xml 在pom.xml中添加下面的插件 <build> <plugins> <plugin> ...

随机推荐

  1. word文档去掉复制过来的背景颜色

    选择清除格式

  2. Google的网站性能优化最佳实践

    网站性能最佳实践   当描述一个web页面的页面速度,评价的一致性遵循许多不同的规则.这些规则是任何阶段的web开发可以应用的前端最佳实践.这个文档的每个规则都陈述于此,无论你是否运行页面测速工具-- ...

  3. PANDAS 数据分析初学者教程

    Pandas 初学者教程       2018-05-19 六尺巷人 对于数据科学家,无论是数据分析还是数据挖掘来说,Pandas是一个非常重要的Python包.它不仅提供了很多方法,使得数据处理非常 ...

  4. android开源新闻小程序、3D翻转公告效果、小说检索、Kotlin开发TODO清单等源码

    Android精选源码 开源新闻小程序源码分享 android动态壁纸.锁屏动画.来电秀等源码 android笔记App效果源码 Android实现3D版翻页公告效果 android小说搜索阅读源码 ...

  5. 关于vuex

    希望初学者可以初步理解vuex的日志: 示意图: 一.图例: 1.Vue Components:Vue组件.HTML页面上,负责接收用户操作等交互行为,执行dispatch方法触发对应action进行 ...

  6. 分布式锁获取token

    package com.sankuai.qcs.regulation.nanjing.util; import com.dianping.squirrel.client.StoreKey; impor ...

  7. 在 CentOS 7 上设置 grub2

    在 CentOS 7 上设置 grub2 1. 开机选单是自动创建出来的 请勿尝试手动编辑开机选单,因为它是按照 /boot/ 目录内的文件自动创建出来的.然而你可以调整 /etc/default/g ...

  8. GDI 映射模式(11)

    概述 调用 SetMapMode 函数可以设置映射模式: int SetMapMode( HDC hdc, // 设备环境句柄 int fnMapMode // 要设置的映射模式 ); 同样,调用 G ...

  9. 【JavaScript高级进阶】JavaScript变量/函数提升的细节总结

    // 测试1 console.log('----------test1--------------'); console.log(global); // undefined var global = ...

  10. CSS 利用transform达到居中效果

    <body> <div class="center"> .... </div> </body> 让left和top都是50%,这在水 ...