无法执行目标org.apache.maven.plugins:maven-compiler-plugin:3.1,无法访问javax.annotation.concurrent.NotThreadSafe

问题描述 投票:0回答:1

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

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>

我可以在pom.xml中看到javax.annotation-api 1.3.1 maven依赖项。找不到javax.annotation.concurrent.NotThreadSafe的静态类文件

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.
file-not-found maven-compiler-plugin
1个回答
0
投票

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

      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.

注意:此解决方案对于所有未找到的类都是通用的。

© www.soinside.com 2019 - 2024. All rights reserved.