1. 程式人生 > 實用技巧 >sonar-scanner提交程式碼掃描報錯

sonar-scanner提交程式碼掃描報錯

sonar-scanner提交程式碼掃描報錯

# sonar-scanner   -Dsonar.projectKey=test_java   -Dsonar.sources=.   -Dsonar.host.url=https://code.bonc.com.cn/sonar   -Dsonar.login=c68b45e9e054938cc1b64429434d9f49b8c6bbd0 -X

報錯如下:

 Error during SonarQube Scanner execution
org.sonar.java.AnalysisException: Please provide compiled classes of your project with sonar.java.binaries property

原因:https://docs.sonarqube.org/latest/analysis/languages/java/,官方文件解釋sonarqube的sonar-java外掛從4.1.2開始,強制要求sonar.java.binaries引數

解決辦法:(兩者自行選擇)

1、下載外掛sonar-java-plugin-4.10.0.10260.jar,替換原有的外掛sonar-java-plugin-4.15.0.12310.jar

2、單模組專案如:
Test
----src
--------java
----target
--------classes

sonar.java.binaries=.(點,不能寫成target/classes,原因不明)

多模組專案如
Test
-----TestParent
-----TestService
-----TestWeb

sonar.java.binaries=TestParent,TestService,TestWeb
sonar.sources=TestParent/src,TestService/src,TestWeb/src

例子:

sonar-scanner -Dsonar.projectKey=test_java  -Dsonar.java.binaries=bxm-common  -Dsonar.sources=bxm-common/src  -Dsonar.host.url=https://code.bono.com/sonar -Dsonar.login=c68b45e9e054938cc1b64429434d9f49b8c6bbd2

參考:https://blog.csdn.net/qq_42030932/article/details/88972835?utm_medium=distribute.pc_relevant.none-task-blog-BlogCommendFromMachineLearnPai2-3.channel_param&depth_1-utm_source=distribute.pc_relevant.none-task-blog-BlogCommendFromMachineLearnPai2-3.channel_param