import javax.annotation.* 無法在 Eclipse 的 Java 10 Compiler 中解析
2022-09-03 03:29:58
在我的机器(Windows 10)中,有两个版本的Java,Java 1.8(JRE和JDK)和Java 10(JRE和JDK)。
以前,如果我将 Eclipse 设置为:
- Java 编译器 (JDK Complience) : 1.8
- Java Build Path (JRE System Libraries) : 1.8
然后,如果我使用以下弹簧代码
import javax.annotation.PostConstruct;
...
...
...
@PostConstruct
...
...
一切都很好。完全没有错误。
但是,如果我将 Eclipse 设置为:
- Java 编译器 (JDK 编译) : 10
- Java Build Path (JRE System Libraries) : 10
现在,该语句正在引发一条错误消息:import
The import javax.annotation.PostConstruct cannot be resolved
这个错误也发生在注释上。@PreDestroy
为什么会发生这种情况?Java 10 会发生什么情况?如果我仍然想保留Java编译器和JRE系统库版本到Java 10,如何解决这个问题?
谢谢。