亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

SonarQube 不使用 IntelliJ 和 Maven 分析主要的 Java 代碼

SonarQube 不使用 IntelliJ 和 Maven 分析主要的 Java 代碼

大話西游666 2021-11-03 14:34:03
我在我的項目中使用 IntelliJ 和 Maven,我必須用 SonarQube 對其進行分析,但是當我使用 webApp 提供的命令掃描我的項目時,它只分析 pom.xml 文件,而忽略了項目的其余部分。分析結果干凈安裝聲納:sonar -Dsonar.host.url= http://localhost:9000 -Dsonar.login="這里對應的key"我的 pom.xml(項目標簽里面是什么):<groupId>cl.itau.simulacionCredito</groupId><artifactId>SimulacionCreditoIntelliJ</artifactId><version>1.0</version><dependencies>    <dependency>        <groupId>org.testng</groupId>        <artifactId>testng</artifactId>        <version>RELEASE</version>        <scope>test</scope>    </dependency>    <!-- https://mvnrepository.com/artifact/com.beust/jcommander -->    <dependency>        <groupId>com.beust</groupId>        <artifactId>jcommander</artifactId>        <version>1.72</version>    </dependency></dependencies><properties>    <maven.compiler.source>6</maven.compiler.source>    <maven.compiler.target>1.6</maven.compiler.target></properties><build>    <plugins>        <plugin>            <groupId>org.apache.maven.plugins</groupId>            <artifactId>maven-surefire-plugin</artifactId>            <version>2.22.0</version>            <configuration>                <excludes>                    <exclude>**/HomeTest.java</exclude>                    <exclude>**/PropuestaTest.java</exclude>                </excludes>            </configuration>        </plugin>        <plugin>            <groupId>org.apache.maven.plugins</groupId>            <artifactId>maven-deploy-plugin</artifactId>            <version>3.0.0-M1</version>        </plugin>        <plugin>            <groupId>org.sonarsource.scanner.maven</groupId>            <artifactId>sonar-maven-plugin</artifactId>            <version>3.5.0.1254</version>        </plugin>    </plugins></build>由于在嘗試解決此問題時出現不同的錯誤,我一直在向 POM 添加內容。我安裝了最新版本的 SonarQube。
查看完整描述

2 回答

?
慕雪6442864

TA貢獻1812條經驗 獲得超5個贊

Sonarqube 通過分析 jacoco 輸出來工作。我在你的 pom 中沒有看到 jacoco 的任何配置。 https://www.petrikainulainen.net/programming/maven/creating-code-coverage-reports-for-unit-and-integration-tests-with-the-jacoco-maven-plugin/是一個關于如何設置的好教程起來。

您還必須告訴 sonarqube 您的 jacoco.exec 文件所在的位置。 https://docs.sonarqube.org/display/PLUG/Code+Coverage+by+Unit+Tests+for+Java+Project


查看完整回答
反對 回復 2021-11-03
?
慕少森

TA貢獻2019條經驗 獲得超9個贊

所以,問題是 IntelliJ 配置了 Java SE 開發工具包 11,我降級到 Java SE 開發工具包 8u181 并配置了 POM,以便 Maven 使用該更改,我再次執行掃描器并且它工作了。


對 pom.xml 的更改:


<properties>

    <maven.compiler.source>1.8</maven.compiler.source>

    <maven.compiler.target>1.8</maven.compiler.target>


    <sonar.sources>src/main/java</sonar.sources>

</properties>

添加:


<plugin>

   <groupId>org.apache.maven.plugins</groupId>

      <artifactId>maven-compiler-plugin</artifactId>

         <version>3.8.0</version>

         <configuration>

            <source>8</source>

            <target>8</target>

         </configuration>

</plugin>


查看完整回答
反對 回復 2021-11-03
  • 2 回答
  • 0 關注
  • 338 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號