zoukankan      html  css  js  c++  java
  • 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

  • 相关阅读:
    大道至简第一张读后感
    字符串加密
    写一个类,在任何时候都可以向它查询创建了多少个类
    类与对象动手动脑
    2016年读书清单
    2016-09-01
    Spring笔记(五)--注解方式实现AOP
    Spring笔记(三)--代理模式
    Spring笔记(四)--公共属性的配置
    表达式之谜
  • 原文地址:https://www.cnblogs.com/biglaojiang/p/3080243.html
Copyright © 2011-2022 走看看