2015-12-07 94 views
2

我试图用maven支持来设置SonarQube(v.4.5.6)。我相信我的配置是正确的,但我无法让SonarQube分析无误地运行。声呐maven分析 - 未找到类

我的项目的依赖关系:

<dependencies> 
    <dependency> 
     <groupId>org.springframework.boot</groupId> 
     <artifactId>spring-boot-starter-actuator</artifactId> 
    </dependency> 
    <dependency> 
     <groupId>org.springframework.boot</groupId> 
     <artifactId>spring-boot-starter-web</artifactId> 
     <exclusions> 
      <exclusion> 
       <groupId>org.springframework.boot</groupId> 
       <artifactId>spring-boot-starter-tomcat</artifactId> 
      </exclusion> 
     </exclusions> 
    </dependency> 
    <dependency> 
     <groupId>org.springframework.boot</groupId> 
     <artifactId>spring-boot-starter-jetty</artifactId> 
    </dependency> 
    <dependency> 
     <groupId>org.springframework.boot</groupId> 
     <artifactId>spring-boot-starter-security</artifactId> 
    </dependency> 
    <dependency> 
     <groupId>org.springframework.security</groupId> 
     <artifactId>spring-security-ldap</artifactId> 
    </dependency> 
    <dependency> 
     <groupId>org.apache.httpcomponents</groupId> 
     <artifactId>httpclient</artifactId> 
     <exclusions> 
      <exclusion> 
       <artifactId>commons-logging</artifactId> 
       <groupId>commons-logging</groupId> 
      </exclusion> 
     </exclusions> 
    </dependency> 
    <dependency> 
     <groupId>org.springframework.boot</groupId> 
     <artifactId>spring-boot-starter-redis</artifactId> 
    </dependency> 
    <dependency> 
     <groupId>com.google.guava</groupId> 
     <artifactId>guava</artifactId> 
     <version>${guava.version}</version> 
    </dependency> 
    <dependency> 
     <groupId>net.logstash.logback</groupId> 
     <artifactId>logstash-logback-encoder</artifactId> 
     <version>${logstash-logback-encoder.version}</version> 
    </dependency> 
    <dependency> 
     <groupId>org.springframework.boot</groupId> 
     <artifactId>spring-boot-starter-test</artifactId> 
     <scope>test</scope> 
    </dependency> 
    <dependency> 
     <groupId>org.powermock</groupId> 
     <artifactId>powermock-module-junit4</artifactId> 
     <version>${powermock.version}</version> 
     <scope>test</scope> 
    </dependency> 
    <dependency> 
     <groupId>org.powermock</groupId> 
     <artifactId>powermock-api-mockito</artifactId> 
     <version>${powermock.version}</version> 
     <scope>test</scope> 
    </dependency> 
    <dependency> 
     <groupId>org.springframework.security</groupId> 
     <artifactId>spring-security-test</artifactId> 
     <version>${spring-security-test.version}</version> 
     <scope>test</scope> 
    </dependency> 
</dependencies> 

声纳Maven的插件:

<plugin> 
    <groupId>org.codehaus.mojo</groupId> 
    <artifactId>sonar-maven-plugin</artifactId> 
    <version>2.7.1</version> 
</plugin> 

SonarQube分析引发以下错误:

[INFO] [19:07:06.235] Source paths: pom.xml, src/main/java 
[INFO] [19:07:06.235] Test paths: src/test/java 
[INFO] [19:07:06.235] Binary dirs: target/classes 
[INFO] [19:07:08.046] Sensor JavaSquidSensor... 
[INFO] [19:07:08.154] Configured Java source version: none 
[INFO] [19:07:08.157] JavaClasspath initialization... 
[INFO] [19:07:08.173] JavaClasspath initialization done: 16 ms 
[INFO] [19:07:08.173] JavaTestClasspath initialization... 
[INFO] [19:07:08.202] JavaTestClasspath initialization done: 29 ms 
[INFO] [19:07:08.412] Java Main Files AST scan... 
[INFO] [19:07:08.414] 27 source files to be analyzed 
[ERROR] [19:07:08.849] Class not found: org.springframework.security.openid.OpenIDAuthenticationFilter 
[ERROR] [19:07:08.850] Class not found: org.springframework.security.openid.OpenIDConsumer 
[ERROR] [19:07:08.850] Class not found: org.openid4java.consumer.ConsumerManager 
[ERROR] [19:07:08.850] Class not found: org.springframework.security.openid.OpenIDAuthenticationToken 
[ERROR] [19:07:08.851] Class not found: org.openid4java.consumer.ConsumerException 
[ERROR] [19:07:08.851] Class not found: org.springframework.security.openid.AxFetchListFactory 
[ERROR] [19:07:08.872] Class not found: org.springframework.jdbc.datasource.init.DatabasePopulator 
[ERROR] [19:07:08.872] Class not found: org.springframework.jdbc.datasource.init.DataSourceInitializer 
[ERROR] [19:07:09.798] Class not found: javax.annotation.Nullable 
[INFO] [19:07:10.163] 27/27 source files have been analyzed 
[INFO] [19:07:10.163] Java Main Files AST scan done: 1751 ms 
[INFO] [19:07:10.165] Java bytecode scan... 
[INFO] [19:07:10.238] Java bytecode scan done: 73 ms 
[INFO] [19:07:10.239] Java Test Files AST scan... 
[INFO] [19:07:10.239] 17 source files to be analyzed 
[ERROR] [19:07:10.400] Class not found: org.springframework.security.openid.OpenIDAuthenticationFilter 
[ERROR] [19:07:10.400] Class not found: org.springframework.security.openid.OpenIDConsumer 
[ERROR] [19:07:10.401] Class not found: org.openid4java.consumer.ConsumerManager 
[ERROR] [19:07:10.401] Class not found: org.springframework.security.openid.OpenIDAuthenticationToken 
[ERROR] [19:07:10.401] Class not found: org.openid4java.consumer.ConsumerException 
[ERROR] [19:07:10.401] Class not found: org.springframework.security.openid.AxFetchListFactory 
[INFO] [19:07:11.114] Java Test Files AST scan done: 875 ms 
[INFO] [19:07:11.114] 17/17 source files have been analyzed 

提到的所有类都不能在项目中使用,对我而言,我更容易混淆可能的错误。

回答

7

您可以看到分析一直运行到最后,没有说失败。分析成功。

这条消息'没找到类':是指?

这是由sonarqube java分析器在分析源文件的依赖关系时引发的。例如,如果您从春季扩展一个类,sonarqube java分析器将查找相应的.class文件。

如果我们有一个规则来计算层次级别的数量,它会查找这个.class文件等等的依赖关系。这意味着它会在你的项目中寻找一些可能不是直接的类。

此消息是无害的,它只是警告您,分析器无法找到一些.class文件,因此您可能会得到较不准确的结果,或者您可能想要修复提供给分析的类路径。

+3

你是对的,分析运行得很好。但是有这些错误出现在日志中有点烦人。我试图找出Sonar能够完美运行的正确类路径配置。 – resilva87

+1

这是Java团队意识到的事情,我们确实想要改善这一点,但目前还没有定义计划。 – benzonico