项目质量保证利器 - Sonar

下载开源工具包:

Sonar : http://www.sonarsource.org/downloads/

Mysql DB : http://dev.mysql.com/downloads/

 

需要配置Sonar的数据

  • 找到Sonar配置文件: %SONAR_HOME%/conf/sonar.properties
  • 修改配置参数,指向既有的DB : URL + Username + Password

  • 启动Sonar

 

配置Sonar插件

POM文件中加入如下配置片段

<pluginRepositories>
    <pluginRepository>
        <id>sonar</id>
        <name>Sonar Plugin</name>
        <url>https://nexus.codehaus.org/content/groups/snapshots-group/</url>
        <releases>
            <enabled>true</enabled>
        </releases>
        <snapshots>
            <enabled>true</enabled>
        </snapshots>
    </pluginRepository>
</pluginRepositories>
 

注意: 需要设置snapshots的enabled为true,因为,默认使用的是false;

 

添加sonar plugin依赖:

<dependency>
  <groupId>org.codehaus.mojo</groupId>
  <artifactId>sonar-maven-plugin</artifactId>
  <version>2.0-SNAPSHOT</version>
</dependency>
 

 

运行Maven命令

mvn clean sonar:sonar -Dsonar.host.url=http://localhost:9000/ -Dsonar.jdbc.url=jdbc:mysql://localhost:3306/sonar -Dsonar.jdbc.driverClassName=com.mysql.jdbc.Driver -Dsonar.jdbc.username=root -Dsonar.jdbc.password=exigen
 

 

查看Sonar的运行结果

登录: http://localhost:9000/

 

==============================================

 

Mysql 数据配置其他机器登陆访问,可以会遇到权限问题,具体详细步骤:

  • 新建一个Sonar专用的DB - create database sonar;

  • 创建一个可以其他机器可以访问的账号 - GRANT ALL PRIVILEGES ON *.* TO 'username'@'%' IDENTIFIED BY 'password' WITH GRANT OPTION;

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值