Windows上的Sonar使用

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/pansanday/article/details/86286821

SonarQube 7.5
数据库MYSQL 5.7
sonar-scanner-3.2.0.1227-windows

一、下载安装
1. sonarqube:
https://www.sonarqube.org/downloads/

2. 中文插件
https://github.com/SonarQubeCommunity/sonar-l10n-zh/releases/tag/sonar-l10n-zh-plugin-1.25

3. sonar-scanner下载
https://docs.sonarqube.org/display/SCAN/Analyzing+with+SonarQube+Scanner


二、配置
1. sonar.properties配置
sonar.jdbc.url=jdbc:mysql://localhost:3306/sonar?useUnicode=true&characterEncoding=utf8&rewriteBatchedStatements=true&useConfigs=maxPerformance&useSSL=false
sonar.jdbc.username=root
sonar.jdbc.password=root
sonar.sourceEncoding=UTF-8

2. sonar-scanner.properties配置
sonar.host.url=http://localhost:9000
sonar.sourceEncoding=UTF-8
sonar.jdbc.url=jdbc:mysql://localhost:3306/sonar?useUnicode=true&characterEncoding=utf8&rewriteBatchedStatements=true&useConfigs=maxPerformance&useSSL=false
sonar.jdbc.username=root
sonar.jdbc.password=root
sonar.sourceEncoding=UTF-8

3. Maven的settings.xml配置
<pluginGroups>
    <pluginGroup>org.sonarsource.scanner.maven</pluginGroup>
</pluginGroups>
<profile>
    <id>sonar</id>
    <activation>
        <activeByDefault>true</activeByDefault>
    </activation>
    <properties>
        <!-- Optional URL to server. Default value is http://localhost:9000 -->
        <sonar.host.url>
          http://localhost:9000
        </sonar.host.url>
    </properties>
</profile>

三、分析
分析sample项目
https://github.com/SonarSource/sonar-scanning-examples

运行命令:
mvn sonar:sonar -Dsonar.host.url=http://localhost:9000 -Dsonar.login=1fb8da8f1102c1ccbbaabd5aa138f4ac98d3147e

四、查看
http://localhost:9000
admin / admin

猜你喜欢

转载自blog.csdn.net/pansanday/article/details/86286821