File not found 未能执行目标org.apache.maven.plugins:maven编译器plugin:3.1,无法访问javax.annotation.concurrent.NotThreadSafe

File not found 未能执行目标org.apache.maven.plugins:maven编译器plugin:3.1,无法访问javax.annotation.concurrent.NotThreadSafe,file-not-found,maven-compiler-plugin,File Not Found,Maven Compiler Plugin,我正在将swagger和相关版本升级到swagger 2。 在执行maven clean安装时,出现以下错误 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

我正在将swagger和相关版本升级到swagger 2。 在执行maven clean安装时,出现以下错误

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.
POM.xml中引发异常的插件:

 <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>

在花了一整天的时间来解决这个问题之后,我找到了系统的方法。下面是:

      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.
注意:此解决方案适用于所有未找到类错误

      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.