0

I am upgrading the swagger and related versions to swagger2. While doing maven clean install getting the below error.

Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project : Compilation failure[ERROR] cannot access javax.annotation.concurrent.NotThreadSafe.

plugin from POM.xml which is throwing exception:

 <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>3.1</version>
        <configuration>
          <source>1.8</source>
          <target>1.8</target>
        </configuration>
 </plugin>

I could see javax.annotation-api 1.3.1 maven dependency in my pom.xml. Still class file for javax.annotation.concurrent.NotThreadSafe not found

Please don't suggest the solutions given in https://stackoverflow.com/questions/42525139/maven-build-compilation-error-failed-to-execute-goal-org-apache-maven-plugins/49299241 or any other stack overflow links. Since I have tried all but no progress.
Kusum
  • 241
  • 5
  • 20

1 Answers1

0

Ok so after spending a full day to sort this out, I have found the systematic approach to it. Here it goes:

      1. As we all know, class file not found error is when compiler is not able to find the class itself. So when you add some dependency, cross check in your repository jar, if class is present there or not(you will find on google that many dependencies claimed for the class, though it wasn't there in any)

      2. To confirm if the class is present, 
            a. Go to the repository directory of the jar file. 
            b. And run command : jar tf {jar_file_name}.jar 
            c. It will list out the classes present in the jar file.

      3. In this way you can add the exact desired dependency required.

Note: this solution is generic for all the class not found error.

Kusum
  • 241
  • 5
  • 20