无法执行目标 org.sonarsource.scanner.maven:sonar-maven-plugin:3.0.1:sonar (default-cli)

Failed to execute goal org.sonarsource.scanner.maven:sonar-maven-plugin:3.0.1:sonar (default-cli)

我安装了 Sonar PMD 插件,然后出现以下错误:

Failed to execute goal org.sonarsource.scanner.maven:sonar-maven-plugin:3.0.1:sonar (default-cli) on project bpm-parent:
  Execution default goal org.sonarsource.scanner.maven:sonar-maven-plugin:3.0.1:sonar failed:
  An API incompatibility was encountered while executing org.sonarscanner.maven:sonar-maven-plugin:3.0.1:sonar:
  java.lang.NoSuchMethodError: org.sonar.plugins.java.api.JavaResourceLocator.classpath()Ljava/llection;
-----------------------------------------------------
realm = plugin>org.sonarsource.scanner.maven:sonar-maven-plugin:3.0.1
strategy = org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy
urls[0] = file:/C:/Users/yogas/.m2/repository/org/sonarsource/scanner/maven/sonar-maven-plugin/3.0.1/sonar-maven-plugin-3.0.1.jar
urls[1] = file:/C:/Users/yogas/.m2/repository/org/apache/maven/shared/maven-dependency-tree/2.2/maven-dependency-tree-2.2.jar
urls[2] = file:/C:/Users/yogas/.m2/repository/org/codehaus/plexus/plexus-component-annotations/1.5.5/plexus-component-annotations-1.5.5.ja
urls[3] = file:/C:/Users/yogas/.m2/repository/org/eclipse/aether/aether-util/0.9.0.M2/aether-util-0.9.0.M2.jar
urls[4] = file:/C:/Users/yogas/.m2/repository/org/sonatype/plexus/plexus-sec-dispatcher/1.4/plexus-sec-dispatcher-1.4.jar
urls[5] = file:/C:/Users/yogas/.m2/repository/org/sonatype/plexus/plexus-cipher/1.4/plexus-cipher-1.4.jar
urls[6] = file:/C:/Users/yogas/.m2/repository/org/codehaus/plexus/plexus-utils/3.0.22/plexus-utils-3.0.22.jar
urls[7] = file:/C:/Users/yogas/.m2/repository/org/sonarsource/sonar-runner/sonar-runner-api/2.5.1/sonar-runner-api-2.5.1.jar
urls[8] = file:/C:/Users/yogas/.m2/repository/commons-lang/commons-lang/2.6/commons-lang-2.6.jar
urls[9] = file:/C:/Users/yogas/.m2/repository/com/google/guava/guava/18.0/guava-18.0.jar
urls[10] = file:/C:/Users/yogas/.m2/repository/com/google/code/findbugs/jsr305/2.0.3/jsr305-2.0.3.jar
Number of foreign imports: 1
  import: Entry[import  from realm ClassRealm[maven.api, parent: null]]             

这看起来很简单:

An API incompatibility was encountered...

一般来说,您应该检查 Plugin Version Matrix 以确保您要安装的插件版本与您的服务器版本兼容。

然而,特别是在这种情况下,它似乎是 PMD 插件版本与它所依赖的 Java 插件版本之间的不兼容(感谢 Julien!)。尝试确保您安装了最新版本的两者。