在sonarqube 7.4的扩展文件夹中添加了自定义插件jar之后,我尝试使用干净的sonar:sonar包构建一个示例项目。但是每次它都给出这个PluginContainerException。该错误在下面共享:
[ERROR] Failed to execute goal
org.sonarsource.scanner.maven:sonar-maven-plugin:3.5.0.1254:sonar
(default-cli) on project testsonar: Execution default-cli of goal
org.sonarsource.scanner.maven:sonar-maven-plugin:3.5.0.1254:sonar
failed: A required class was missing while executing
org.sonarsource.scanner.maven:sonar-maven-plugin:3.5.0.1254:sonar:
org/sonar/java/model/PackageUtils [ERROR]
-----------------------------------------------------
[ERROR] realm = plugin>org.codehaus.mojo:sonar-maven-plugin:3.5.0.1254 [ERROR]
strategy = org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy
[ERROR] urls[0] =
file:/C:/Users/chakrabok/.m2/repository/org/sonarsource/scanner/maven/sonar-maven-plugin/3.5.0.1254/sonar-maven-plugin-3.5.0.1254.jar
[ERROR] urls[1] =
file:/C:/Users/chakrabok/.m2/repository/org/sonatype/plexus/plexus-sec-dispatcher/1.4/plexus-sec-dispatcher-1.4.jar
[ERROR] urls[2] =
file:/C:/Users/chakrabok/.m2/repository/org/sonatype/plexus/plexus-cipher/1.4/plexus-cipher-1.4.jar
[ERROR] urls[3] =
file:/C:/Users/chakrabok/.m2/repository/org/codehaus/plexus/plexus-utils/3.0.22/plexus-utils-3.0.22.jar
[ERROR] urls[4] =
file:/C:/Users/chakrabok/.m2/repository/org/sonarsource/scanner/api/sonar-scanner-api/2.10.0.1189/sonar-scanner-api-2.10.0.1189.jar
[ERROR] urls[5] =
file:/C:/Users/chakrabok/.m2/repository/commons-lang/commons-lang/2.6/commons-lang-2.6.jar
[ERROR] Number of foreign imports: 1 [ERROR] import: Entry[import
from realm ClassRealm[maven.api, parent: null]] [ERROR] [ERROR]
-----------------------------------------------------:org.sonar.java.model.PackageUtils
请告诉我该怎么办?
答案 0 :(得分:0)
您可以使用以下任何一种解决方案来解决此问题:
在Sonarqube web console中停用“安全性注释强制”规则。
在项目的pom.xml中添加以下依赖项:
<dependencies>
...
<dependency>
<groupId>org.sonarsource.java</groupId>
<artifactId>java-squid</artifactId>
<version>3.11</version>
</dependency>
</dependencies>
确保在pom.xml中添加依赖项后,已编译项目( mvn全新安装),然后将jar文件复制到<sonarqube_dir>
/ extensions / plugins / 目录,最后重新启动声纳服务器。
P.S。 org.sonar.java.model.PackageUtils类是由SecurityAnnotationMandatoryRule导入的,其依赖项需要添加到pom.xml中。