• Sonar 安装手册


    前言

    公司前段时间推动项目代码质量评估,发现Sonar不错,能够集成checkstyle,findbugs,pmd的大部分功能。

    Sonar支持三种运行方式: Maven集成,Ant集成,Sonar Runner。

    下载

    到官方网站下载Sonar的压缩包,解压到任意目录

    创建数据库 

    Sonar默认使用嵌入式Derby数据库,如果要迁移到Mysql上,需首先创建一个sonar/sonar的UTF-8的mysql数据库,并授权访问sonar库
    mysql> CREATE DATABASE sonar CHARACTER SET utf8 COLLATE utf8_general_ci;
    mysql> grant all privileges on sonar.\* to 'sonar'@'localhost' identified by 'sonar';
    mysql> flush privileges;

    修改$SONAR_HOME/conf/sonar.properties文件:

    Properties代码:
    #sonar.jdbc.url: jdbc:derby://localhost:1527/sonar;create=true
    #sonar.jdbc.driver: org.apache.derby.jdbc.ClientDriver
    #sonar.jdbc.defaultTransactionIsolation: 1
    #sonar.jdbc.validationQuery: values(1)
    sonar.jdbc.url: jdbc:mysql://localhost:3306/sonar?useUnicode=true&characterEncoding=utf8
    sonar.jdbc.driver: com.mysql.jdbc.Driver
    sonar.jdbc.validationQuery: select 1

    配置maven2 

    编辑位于$MAVEN_HOME/conf 下的settings.xml文件 

    <profile>  
        <id>sonar</id>  
        <activation>  
            <activeByDefault>true</activeByDefault>  
        </activation>  
        <properties>  
            <sonar.jdbc.url>  
                jdbc:mysql://localhost:3306/sonar?useUnicode=true
            </sonar.jdbc.url>  
            <sonar.jdbc.driver>com.mysql.jdbc.Driver</sonar.jdbc.driver>  
            <sonar.jdbc.username>sonar</sonar.jdbc.username>  
            <sonar.jdbc.password>sonar</sonar.jdbc.password>  
            <sonar.host.url>http://localhost:9000</sonar.host.url>  
        </properties>  
    </profile>

    启动sonar 

    执行位于以下脚本
    $SONAR_HOME/bin/$OS_VERSION/**

    在maven工程下运行mvn sonar:sonar

  • 相关阅读:
    在HTML网页中嵌入脚本的方式
    纪念品分组(贪心、排序)
    合并果子(STL优先队列)
    铺地毯(取最上层的地毯)
    多项式方程的输出
    BF算法(蛮力匹配)
    数位的处理
    两个数的差
    多项式计算器
    随机数生成器java实现
  • 原文地址:https://www.cnblogs.com/biglaojiang/p/3080243.html
Copyright © 2020-2023  润新知