Syntax error, annotations are only available if source level is 1.5 or greater

前言

在学习一个参考工程,在我这用eclipse打开后,显示有很多错误。
现在工程代码翻的差不多了, 准备开始动态调试,要解决这些编译错误。

看到错误提示是”Syntax error, annotations are only available if source level is 1.5 or greater”
可能我这jdk版本(jdk-8u161-windows-x64)和eclipse的编译设置(eclipse-java-kepler-SR1-win32-x86_64)和同事不一样吧。
https://*.com/questions/1736730/eclipse-magic-syntax-error-varargs-are-only-available-if-source-level-is-1 这有个解决方法.

实验

Syntax error, annotations are only available if source level is 1.5 or greater
Syntax error, annotations are only available if source level is 1.5 or greater
选编译设置时,要来2次,使”Compiler compliance level”的改变使工程重新编译。改成1.5,点击确定。再来一次,改1.7, 点击确定。再编译出来的工程,就没有错误提示了。
为啥要来2次呢,因为我第一次修改前,”Compiler compliance level”就是1.7,可能是eclipse的bug吧。或者要找到eclipse重新编译的直接方法。可能我还没动态调试呢,所以工程没有重新编译。

哦,去查eclipse重新编译的方法,原来clean工程时,就可以选是否自动编译工程.
Syntax error, annotations are only available if source level is 1.5 or greater
Syntax error, annotations are only available if source level is 1.5 or greater