How can be solved java.lang.NoClassDefFoundError: javax/annotation/Generated?

implementation 'javax.annotation:javax.annotation-api:1.3.2'
annotationProcessor("javax.annotation:javax.annotation-api:1.3.2")

From 2020 onwards, the javax.* modules have been transitioned to jakarta. So the 2020+ proof dependency declaration is now:

<groupId>jakarta.annotation</groupId>
<artifactId>jakarta.annotation-api</artifactId>

See also a blog with explanations and a complete table with old and new names


I had same problem and fixed by adding library javax.annotation-api-1.3.2.jar


Add an artifact containing the classes you need to the classpath.

It appears that the javax.annotation API is what you need. See https://mvnrepository.com/artifact/javax.annotation/javax.annotation-api/1.3.2 for details. You can add the following dependency to your project as any other and it should be present:

<!-- https://mvnrepository.com/artifact/javax.annotation/javax.annotation-api -->
<dependency>
    <groupId>javax.annotation</groupId>
    <artifactId>javax.annotation-api</artifactId>
    <version>1.3.2</version>
</dependency>

Remember to remove the compiler arguments!