gpt4 book ai didi

java - Sonar maven 分析 - 找不到类

转载 作者:搜寻专家 更新时间:2023-10-31 08:25:37 25 4
gpt4 key购买 nike

我正在尝试使用 Maven 支持设置 SonarQube (v.4.5.6)。我相信我的配置是正确的,但我无法让 SonarQube 分析正常运行。

我的项目的依赖:

<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>

Sonar -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

所有提到的类都没有在项目中使用,对我来说这让我更困惑可能是什么错误。

最佳答案

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

此消息“未找到类:”是什么意思?

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

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

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

关于java - Sonar maven 分析 - 找不到类,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34143530/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com