Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

I use gRPC to generate java code '@javax.annotation.Generated' and it reports 'Error:(20,18) java: cannot find symbol'. How to solve it?

I use gRPC to generate code '@javax.annotation.Generated' like below picture.

![enter image description here

Then I use maven to build the project, and it reports 'Error:(20,18) java: cannot find symbol' like below picture.

enter image description here

How to solve it?

like image 258
陈黎栋John Avatar asked Dec 21 '25 15:12

陈黎栋John


2 Answers

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>
like image 135
creamsoup Avatar answered Dec 23 '25 04:12

creamsoup


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.

like image 42
Klesun Avatar answered Dec 23 '25 06:12

Klesun



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!