版权声明:本文为博主原创文章,转载请注明出处【by:待孤君临天下】
前言:相信大家在 Eclipse 上编写项目或者移植项目的时候都会有出现过各种各样奇葩搞笑的问题。不管你有没有,反正本人遇见了各种各样的错误。在这里记录下各种各样的错误,以防后面再次遇到相同的错误又要百度,顺便提供给遇到相同错误的开发者提供参考。
系统环境:
Windows 10
Eclipse 版本 :Version: Photon Release (4.8.0)
Build id: 20180619-1200
JDK 版本 :java version "10.0.1" 2018-04-17
Tomcat 版本:apache-tomcat-9.0.10
1、Java compiler level does not match the version of the installed Java project facet.

解决方案:出现这个问题的原因是因为,eclipse 的 JDK 编译版本与出现问题的项目 JDK 编译版本不一致所导致!
(1)、先确定项目所需要用到的 JDK 版本,然后将 Eclipse 里面的 JDK 版本设置为你所需要的 JDK 版本。(windows -》proferences -》java -》Installed JREs / compiler)


(2)在项目的设置当中也设置为相同的 JDK 版本(右击项目 -》 properties -》java Compiler / Project Facets)。


2、Target runtime Apache Tomcat v7.0 is not defined.

解决方案:运行时没有找到 Tomcat v7.0。
1、在项目中更改运行的 Tomcat (右击项目 -》 properties -》Target Runtimes)。

3、-Djava.endorsed.dirs=D:\Java\Tomcat\apache-tomcat-9.0.10\endorsed is not supported. Endorsed standards and standalone APIs in modular form will be supported via the concept of upgradeable modules.


PS:这次的 Eclipse版本为 Oxygen.3a Release (4.7.3a)
解决方案:替换 org.eclipse.jst.server.tomcat.core_1.1.902.v201805281856.jar 这个包
具体原因可以参考 博客
或者更新到楼主的 Eclipse 版本也可以解决
4、Cannot change version of project facet Dynamic Web Module to 4.0.

解决方案:错误是指当前的 web.xml 配置的 j2ee 版本和项目中的 project facets 的 j2ee 版本不一致导致(也就是 web.xml 的写法错误)。
5、The superclass "javax.servlet.http.HttpServlet" was not found on the Java Build Path

解决方案:错误是因为没有添加 Tomcat 相关类,说来就是没有添加 Tomcat 相关jar
方法一:右击项目 -> Properties -> Targeted Runtimes -> 选择你所创建的 Tomcat 版本 -> 点击 Apply -> 点击 Apply And Close

方法二 :右击项目 -> Build Path -> Configure Build Path -> Add Library -> Server Runtime

选择你需要的 Tomcat 版本,点击 Finish

6、警告 / 错误信息:有可能是警告也有可能是错误,因为我这边出现过警告,也出现过错误。Build path specifies execution environment J2SE-1.5. There are no JREs installed in the workspace that are strictly compatible with this environment.
PS:Java compiler level does not match the version of the installed Java project facet.这个问题也可以按照下面的方法操作


(1)点击 windows -> show view -> Navigator

(2)修改 org.eclipse.jdt.core.prefs 文件 (PS :记得保存后在进行下一步)

(3)修改 org.eclipse.wst.common.component 文件(PS :记得保存后在进行下一步)

(4)修改 web.xml 文件 参考 (PS :记得保存后在进行下一步)

(5)修改 org.eclipse.wst.common.project.facet.core.xml 文件 (PS :记得保存后在进行下一步)

(6)切换回 Project Explorer 视图,右击项目 -> Properties -> Java Comipler -> Apply

(7)右击项目 -> Properties -> Project Facets -> Apply
修改成跟第五部设置的一样版本

(8)右击项目 -> Properties -> Java Build Path -> Library -> JRE System Library [J2SE-1.5] -> Edit -> Workspace default JRE(10.0.1) -> Finish


(9)点击 Apply and Close 。
网友评论