import javax.annotation.* cannot be resolved in Eclipse's Java 10 Compiler

后端 未结 3 1977
名媛妹妹
名媛妹妹 2021-01-11 14:15

In my machine (Windows 10), there are two versions of Java, Java 1.8 (JRE and JDK) and Java 10 (JRE and JDK).

Previously IF I set my Eclipse

相关标签:
3条回答
  • 2021-01-11 15:08

    Well This happens Because @PostConstruct and @preDestroy are deprecated in java 9 onwards so better not to use them instead use interface to resolve this

    0 讨论(0)
  • 2021-01-11 15:08

    Add javax.annotation-api-1.3.2.jar to your classpath. It works with JDK 10 as well.
    For more clarity on alternative approaches, go through below video link:

    https://www.youtube.com/watch?v=jOYSRwwMLX8&list=PLzS3AYzXBoj9IBdtgXRSyZEwlU2QV-mGG&index=6

    0 讨论(0)
  • 2021-01-11 15:10

    You can try to add annotation dependencies to pom.xml, so that they would be available for Spring:

    <dependency>
      <groupId>javax.annotation</groupId>
      <artifactId>javax.annotation-api</artifactId>
      <version>1.3.2</version>
    </dependency>
    
    0 讨论(0)
提交回复
热议问题