360SDN.COM

SSH之JDK1.8遇错The type java.util.Map$Entry cannot be resolved.

来源:  2018-07-18 15:00:11    评论:0点击:

 SSH我们使用的时候大部分使用的是他自身带的平台和自带的tomcat服务器,但是一旦自己的项目放到自己的开发平台上事情就不是太美好了,这不是我就遇到了这么一个难过的问题“The type java.lang.CharSequence cannot be resolved. It is indirectly referenced from required .class files
The type java.util.Map$Entry cannot be resolved. It is indirectly referenced from required .class files”,自己查了很多的资料但是这个一大串的英文单词真的是很考验我们的耐性呀!

    后来在网上查了一下解释,是因为eclipse 对1.8的不支持所致,最起码我的是这样,然后我去eclipse 官网去查看,发现eclipse直到4.3.2 版本才完全对jdk1.8支持,引用:contain full support for Java™ 8. For Kepler SR2 (4.3.2) !

   我真的快哭死了,其实因为版本问题我们遇到的问题很多,最好我把我的myeclipse改成了14的!

  
来源:https://blog.csdn.net/songsong189/article/details/50667475



今天使用Eclipse搭建SpringMVC环境的时候,遇到一个Error:

 

An error occurred at line: 1 in the generated java file
The type java.util.Map$Entry cannot be resolved. It is indirectly referenced from required .class files

Stacktrace:
    at org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:92)
    at org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:330)
    at org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:439)
    at org.apache.jasper.compiler.Compiler.compile(Compiler.java:356)
    at org.apache.jasper.compiler.Compiler.compile(Compiler.java:334)
    at org.apache.jasper.compiler.Compiler.compile(Compiler.java:321)

本地环境:

java version “1.8.0_45”

apache-tomcat-6.0.35

Eclipse Java EE IDE for Web Developers. Version: Luna Service Release 2 (4.4.2)

解决办法:

国内网站简单查了下,全说降低JDK版本。没明白根本原因,然后在StackOverFlow找到解答。下面是链接。

StackOverFlow 
里面这么说:

When using JDK 8 and an IDE with its own compiler, like Eclipse, you have to update the IDE to a version with Java 8 support, even if you are not using the newer Java 8 features.

The reason is that the [应该是指Eclipse] compiler must be able to load the newer class files of the JRE(应该是指JRE8) in order to compile your software which references these classes.

Sometimes you can get away with an older compiler when it ignores the newer version number of the class files. But some types will confuse older class file parsers as they use new features, notably(尤其是) AnnotatedElement, which now has default methods, and Map.Entry, an interface which now has static methods.

It seems that Eclipse does not make a difference between references for which no class file could be found and class files it failed to read when saying “«classname» cannot be resolved”.

可以看出,出问题的不是JRE/JDK什么的,是IDE的问题。

本地解决办法: 
降级到JDK7,加入rt.jar到/WebContent/WEB-INF/lib下。

为您推荐

友情链接 |九搜汽车网 |手机ok生活信息网|ok生活信息网|ok微生活
 Powered by www.360SDN.COM   京ICP备11022651号-4 © 2012-2016 版权