【问题标题】:Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1,Cannot access javax.annotation.concurrent.NotThreadSafe执行目标 org.apache.maven.plugins:maven-compiler-plugin:3.1 失败,无法访问 javax.annotation.concurrent.NotThreadSafe
【发布时间】:2019-11-28 08:50:50
【问题描述】:

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

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

          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.
    

    注意:此解决方案适用于所有未找到类错误。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-01-04
      • 2022-08-10
      • 2018-10-05
      • 2017-06-23
      • 1970-01-01
      • 2017-02-18
      相关资源
      最近更新 更多