简体   繁体   中英

Java 9 migration javax.annotation

So i try to migrate my project to Java 9 but the process seems not so easy as i thought it would be. I kept getting some errors about invisible packages that i could fix with the following argument in my pom:

<compilerArgs>
     <arg>--add-modules</arg>
     <arg>java.se.ee</arg>
</compilerArgs>

But i still get the following error:

cannot find symbol
[ERROR]   symbol:   class Priority
[ERROR]   location: package javax.annotation

any help would be appreciated

I'm not sure where javax.annotation.Priority comes from, but a solution analog to getting JSR 305 running on Java 9 should fix your problem: Instead of adding the (deprecated) Java EE module java.xml.ws.annotation (which you do indirectly by adding java.se.ee ), you should instead add the javax.annotation package from an external artifact, namely javax.annotation:javax.annotation-api .

If you modularize your code, that solution no longer works and you have to start patching modules . Or, even better, move away from solutions that require non-JDK classes that pretend to come from java or javax packages because that will always cause problems.

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