JDK从1.7切换到1.8,Myeclipse10.0导入之前运行正常的工程提示如下错误:
Description Resource Path Location Type
The project was not built since its build path is incomplete. Cannot find the class file for java.lang.reflect.AnnotatedElement. Fix the build path then try building this project analysis_system Unknown Java Problem
Description Resource Path Location Type
The type java.lang.reflect.AnnotatedElement cannot be resolved. It is indirectly referenced from required .class files SpringContextsUtil.java /analysis_system/src/main/java/cn/geekview/analysisSystem/utils line 1 Java Problem
解答:
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 compiler must be able to load the newer class files of the JRE 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”.
实际上就是Myeclipse的版本太低不支持JDK1.8,所以更新开发工具的版本即可解决,我个人切换到IDEA上运行就解决这个问题了!