SonarQube搭建

SonarQube搭建:
环境 : windows, jdk1.8 ,maven
1. 官网下载SonarQube版本,我这里下载的7.2.1版本, 官网下载地址: http://www.sonarqube.org/downloads/ ,
2. 启动: sonarqube-7.2.1\bin\windows-x86-64\StartSonar.bat, 浏览器打开localhost:9000, 即可看到SonarQube Web首页
3. 下面连接mysql数据库,我这里新建了fangqian_sonar_db:
修改 sonarqube-7.2.1\conf\sonar.properties

sonar.jdbc.url=jdbc:mysql://dev-mysql-m.a.pa.com:3306/fangqian_sonar_db?useUnicode=true&characterEncoding=utf8&rewriteBatchedStatements=true&useConfigs=maxPerformance&useSSL=false

sonar.jdbc.username=dev

sonar.jdbc.password=dev

sonar.sorceEncoding=UTF-8

sonar.login=admin

sonar.password=admin

sonar.web.host=0.0.0.0 (可以改成允许访问的IP)

sonar.web.context=/ (浏览器端口后跟的访问路径)

sonar.web.port=9000

  1. 下载SonarQube Scanner for Maven插件,
    官网上写的:

From maven-sonar-plugin 3.4.0.905, SonarQube < 5.6 is no longer supported.

If using SonarQube instance prior to 5.6, you should use maven-sonar-plugin 3.3.0.603.

From maven-sonar-plugin 3.1, Maven < 3.0 is no longer supported.

If using Maven prior to 3.0, you should use maven-sonar-plugin 3.0.2.

我们的maven的版本是3.0以上, 下载3.0.2以上版本的插件
5. 修改maven的setting.xml
添加以下节点配置:

<settings>

    <pluginGroups>

        <pluginGroup>org.sonarsource.scanner.maven</pluginGroup>

    </pluginGroups>

    <activeProfiles>

        <activeProfile>sonar</activeProfile>

    </activeProfiles>

    <profiles>

        <profile>

            <id>sonar</id>

            <properties>

                <sonar.host.url>http://localhost:9000</sonar.host.url>

                <sonar.jdbc.driver>com.mysql.jdbc.Driver</sonar.jdbc.driver>

                <sonar.jdbc.username>dev</sonar.jdbc.username>

                <sonar.jdbc.password>dev</sonar.jdbc.password>

                <sonar.jdbc.url>jdbc:mysql://dev-mysql-m.a.pa.com:3306/fangqian_sonar_db</sonar.jdbc.url>

                <!-- 不想扫描的包目录 -->

                <sonar.exclusions>src/main/java/com/odlfy/.../**/*</sonar.exclusions>

            </properties>

        </profile>

    </profiles>

</settings>

  1. 进入想扫描的maven项目根目录, 执行maven 命令 mvn clean install sonar:sonar ,
    扫描完成后, 重新打开http://localhost:9000 可以看到check的project结果
    注意:

If you get an java.lang.OutOfMemoryError, you can set the MAVEN_OPTS environment variable, like this in *nix environments:

export MAVEN_OPTS="-Xmx512m"

On Windows environments, avoid the double-quotes, since they get misinterpreted.

set MAVEN_OPTS=-Xmx512m

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值