I use gRPC to generate code '@javax.annotation.Generated' like below picture.
Then I use maven to build the project, and it reports 'Error:(20,18) java: cannot find symbol' like below picture.
How to solve it?
I use gRPC to generate code '@javax.annotation.Generated' like below picture.
Then I use maven to build the project, and it reports 'Error:(20,18) java: cannot find symbol' like below picture.
How to solve it?
you can add javax.annotation-api
dependencies to you maven pom.xml
to resolve the annotation.
<dependency>
<groupId>javax.annotation</groupId>
<artifactId>javax.annotation-api</artifactId>
<version>1.2</version>
</dependency>
In my case this was caused by building the project on a system with too new version of Java accidentally installed (19 instead of 8). Changing Java version from 19 to 8 in File -> Project Structure fixed the issue for me.
When I use querydsl, I meet the same similar situation in generated source.
I solved this ploblem by uncheck "Use '--release' option for cross-compilation (Java 9 and later ) in Setting "Build, Execution, Deployment > Compiler > Java Compiler" menu.
My problem involved upgrading my Java platform (JDK8 -> JDK17) underneath the codebase (which contained Swagger codegen files).
Solution was to mass-refactor all @javax.annotation.Generated
to @javax.annotation.processing.Generated
. No dependency changes.
I was also facing similar issue for project https://github.com/eugenp/tutorials/tree/master/spring-web-modules/spring-rest-query-language .
Issue - parent and spring-rest-query-language module have source and target as java 8. But I wanted to run this with Intellij having openjdk 21. Few other modules were working correctly with openjdk21 but this module was showing error-
class Generated not found error, javax.annotation.processing Generate not found
Solution -
2.I have changed the source and target to 21 as mentioned below snapshot ( in top menu -> Intellij IDEA -> settings -> Build, Execution, Deployment -> java compiler).
For people not wanting to add a dependency on javax.*
, it looks like a solution for this was released with the 1.63.0 release of gRPC-java: https://github.com/grpc/grpc-java/pull/10927#issuecomment-2066632469.
© 2022 - 2024 — McMap. All rights reserved.