建立maven工程pom文件没错报红x解决

建立完maven工程以后pom文件没有错 可是一直报红叉。
在这里插入图片描述
pom文件没任何问题 红叉就是一直在 百度有的说 update project就能够了然而 没卵用。
首先看红错缘由 是由于缺乏web.xml 将错误复制 百度,有一个带佬 说的很详细如下是转自那位大哥的:
提示信息应该能看懂。也就是缺乏了web.xml文件,被设置成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 war. 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文件中手动添加以下配置:
在这里插入图片描述
“告知”maven便可。这样作的好处是咱们没必要在项目生中成一个无用的web.xml文件。在更新版本(具体从哪个版本开始我也不知道~~)的maven中已经不存在web.xml文件缺失的问题,咱们只须要处理被设置成tue的问题便可。也就是在pom.xml中添加以下配置便可。
在这里插入图片描述
其余方案:(生成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应用正常运行。
通过这两步,问题解决。
java

原文地址:https://blog.csdn.net/sinat_22911279/article/details/77454139web

对于黄色警告之一和这个项目相关的警告
在这里插入图片描述
也找到了解决的方法:
项目中须要三个地方的jdk版本保持一致,保证编译经过:
1.点击项目右键 properties->projeact Facets 下拉选择你当前安装的jdk版本
在这里插入图片描述
2.右键properties->java Conpiler
在这里插入图片描述
3.单击菜单栏window->preference->java->Installed JREs
在这里插入图片描述
没添加的话 就点击add按钮 添加你的jdk。浏览器