当前位置: 首页 > 知识库问答 >
问题:

无法执行目标组织。阿帕奇。专家插件:maven编译器插件:3.1,无法访问javax。注释。同时发生的不安全

赫连彬炳
2023-03-14

我正在将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>

我可以看到javax.annotation-api 1.3.1 maven依赖在我的pom.xml.仍然类文件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.

共有1个答案

华章横
2023-03-14

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

      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.

注意:这个解决方案是通用的所有类没有找到错误。

 类似资料: