Cannot find javax.annotation.Generated in Java 11

Task

When I tried to run the gRPC sample code on Java 11, the code generation worked, but it stopped with the following error at runtime.

error:Can't find symbol
@javax.annotation.Generated(
                 ^
symbol:Class Generated
place:Package javax.annotation

solution

Issue Java 11: cannot find symbol javax.annotation.Generated # 5343 of grpc / grpc-java Add the Javax Annotation API to dependencies as described in grpc-java / issues / 5343). (It is reported that this issue itself does not work if you insert a conditional branch of Java9, but it will work if you do not insert a conditional branch like ↓.)

build.gradle (excerpt)


dependencies {
    implementation 'io.grpc:grpc-netty-shaded:1.23.0'
    implementation 'io.grpc:grpc-protobuf:1.23.0'
    implementation 'io.grpc:grpc-stub:1.23.0'
    compile 'javax.annotation:javax.annotation-api:1.3.2'  //← Add this line
    testCompile group: 'junit', name: 'junit', version: '4.12'
}

Check the Maven Repository for the latest version of the Javax Annotation API. https://mvnrepository.com/artifact/javax.annotation/javax.annotation-api

Recommended Posts

Cannot find javax.annotation.Generated in Java 11
Find a subset in Java
Partization in Java
Changes in Java 11
Rock-paper-scissors in Java
What Java programmers find useful in Kotlin
Pi in Java
FizzBuzz in Java
Be careful if you find SHIFT-JIS in Java
[java] sort in list
Read JSON in Java
Interpreter implementation in Java
Make Blackjack in Java
Rock-paper-scissors app in Java
Constraint programming in Java
Put java8 in centos7
NVL-ish guy in Java
Combine arrays in Java
"Hello World" in Java
Comments in Java source
Azure functions in java
Format XML in Java
Simple htmlspecialchars in Java
Boyer-Moore implementation in Java
Hello World in Java
Use OpenCV in Java
webApi memorandum in java
Type determination in Java
Ping commands in Java
Various threads in java
Heapsort implementation (in java)
Zabbix API in Java
ASCII art in Java
Compare Lists in Java
POST JSON in Java
Express failure in Java
Create JSON in Java
Date manipulation in Java 8
What's new in Java 8
Use PreparedStatement in Java
What's new in Java 9,10,11
Parallel execution in Java
Initializing HashMap in Java
I tried to find out what changed in Java 9
Try using RocksDB in Java
Read binary files in Java 1
Avoid Yubaba's error in Java
Get EXIF information in Java
Save Java PDF in Excel
[Neta] Sleep Sort in Java
Edit ini in Java: ini4j
Let Java segfault in 6 lines
Try calling JavaScript in Java
Try developing Spresense in Java (1)
Try functional type in Java! ①
Cannot communicate in docker-compose container
I made roulette in Java.
Create hyperlinks in Java PowerPoint
Implement two-step verification in Java
Refactoring: Make Blackjack in Java
Write flyway callbacks in Java