提示信息应该能看懂。也就是缺少了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文件中手动添加如下配置:

  1. <build>
  2. <plugins>
  3. <plugin>
  4. <groupId>org.apache.maven.plugins</groupId>
  5. <artifactId>maven-war-plugin</artifactId>
  6. <version>2.6</version>
  7. <configuration>
  8. <failOnMissingWebXml>false</failOnMissingWebXml>
  9. </configuration>
  10. </plugin>
  11. </plugins>
  12. </build>

“告知”maven即可。这样做的好处是我们不必在项目生中成一个无用的web.xml文件。在更新版本(具体从哪一个版本开始我也不知道~~)的maven中已经不存在web.xml文件缺失的问题,我们只需要处理<failOnMissingWebXml>被设置成tue的问题即可。也就是在pom.xml中添加如下配置即可。

  1. <properties>
  2. <failOnMissingWebXml>false</failOnMissingWebXml>
  3. </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. 常用MIME类型(Flv,Mp4的mime类型设置)

    也许你会在纳闷,为什么我上传了flv或MP4文件到服务器,可输入正确地址通过http协议来访问总是出现“无法找到该页”的404错误呢?这就表明mp4格式文件是服务器无法识别的,其实,这是没有在iis中 ...

  2. Spring Boot (18) @Async异步

    通常我们在某网站发送邮件验证码时,首先会提示验证码已发送,然而此时可能没有收到验证码,过几秒种才真正的收到.如果是同步会先验证发送是否成功然后再通知,如果是异步可以先通知用户已发送,并释放请求,然后再 ...

  3. Spring Boot (5) Spring Boot配置详解

    application.properties application.properties是spring boot默认的配置文件,spring boot默认会在以下两个路径搜索并加载这个文件 src\ ...

  4. 【Linux】七种文件类型

    Linux中的七种文件类型 d 目录文件. l 符号链接(指向另一个文件). s 套接字文件. b 块设备文件,二进制文件. c 字符设备文件. p 命名管道文件. - 普通文件

  5. js动态操作订单表格

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...

  6. 如何实现MySQL数据库使用情况的审计

    如何实现MySQL数据库使用情况的审计   最佳答案   mysql的审计功能 mysql服务器自身没有提供审计功能,但是我们可以使用init-connect + binlog的方法进行mysql的操 ...

  7. PythonOpenCV:MLP用于最近邻搜索

    一:简单C++版本的链接: http://blog.csdn.net/kaka20080622/article/details/9039749 OpenCV的ml模块实现了人工神经网络(Artific ...

  8. Python2X和Python3X 除法运算符的使用:

    首先注明:如果没有特别说明,以下内容都是基于python 3.4的. 1. /是精确除法,//是向下取整除法,%是求模 2. %求模是基于向下取整除法规则的 3. 四舍五入取整round, 向零取整i ...

  9. vue移动端Ui组件 mint-ui 使用指南

    1.上啦加载下拉刷新的使用 this.$refs.loadmore.onTopLoaded(); this.$refs.loadmore.onBottomLoaded(); 上啦刷新下拉加载的 动画显 ...

  10. PAT_A1129#Recommendation System

    Source: PAT A1129 Recommendation System (25 分) Description: Recommendation system predicts the prefe ...