简体   繁体   中英

Maven update in Java 9, Maven compile in Java 8 in Eclipse

I have a project with Spring and Maven using Java version 8. When I run maven update it works with Java 9 or higher and when I compile it works well with Java 8. I have noticed this because updating with Maven changes a specific class to Java 9 and I cannot import this class.

The class is: javax.annotation.Generated (Java 8).

This is the class to import. However when I do a maven update the import of the file changes the class to: javax.annotation.processing.Generated (Java 9 or higher) and the import fails. When I compile the import of the class it goes back to javax.annotation.Generated

I have to say that I updated the project to the latest version of Spring a few days ago and now I have the problem.

Can anyone help with this?

Thanks in advance.

JDK/JRE has become smaller, and everything that is in javax.* we have to import ourself. Add this to your pom file:

<dependency>
    <groupId>javax.annotation</groupId>
    <artifactId>javax.annotation-api</artifactId>
    <version>1.3.2</version>
</dependency>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM