快速搭建sonar代码质量管理平台

原文地址:http://blog.csdn.net/honglei915/article/details/38272435

安装

  1. 下载,直接解压http://www.sonarqube.org/downloads/
  2. 添加mysql驱动至\extensions\jdbc-driver\mysql\
  3. 创建mysql数据库和用户:10.22.10.139 db:sonar 用户名/密码:sonar/sonar
  4. 修改sonar.properties,注释掉默认的数据库配置,添加以下配置:
    [plain]  view plain  copy
      在CODE上查看代码片 派生到我的代码片
    1. #----- MySQL 5.x  
    2. # Comment the embedded database and uncomment the following line to use MySQL  
    3. sonar.jdbc.url=jdbc:mysql://10.22.10.139:3306/sonar?useUnicode=true&characterEncoding=utf8&rewriteBatchedStatements=true  
  5. 启动bin/sonar.sh start
  6. 登陆http://localhost:9000/   用户名/密码:admin/admin

使用maven分析项目:

  • 在Maven的settings.xml(全局配置文件,不是项目的pom.xml)中添加以下配置:

[html]  view plain  copy
  在CODE上查看代码片 派生到我的代码片
  1. <settings>  
  2.     <profiles>  
  3.         <profile>  
  4.             <id>sonar</id>  
  5.             <activation>  
  6.                 <activeByDefault>true</activeByDefault>  
  7.             </activation>  
  8.             <properties>  
  9.                 <!-- Example for MySQL-->  
  10.                 <sonar.jdbc.url>  
  11.                   jdbc:mysql://10.22.10.139:3306/sonar?useUnicode=true&characterEncoding=utf8  
  12.                 </sonar.jdbc.url>  
  13.                 <sonar.jdbc.username>sonar</sonar.jdbc.username>  
  14.                 <sonar.jdbc.password>sonar</sonar.jdbc.password>  
  15.    
  16.                 <!-- Optional URL to server. Default value is http://localhost:9000 -->  
  17.                 <sonar.host.url>  
  18.                   http://10.22.10.139:9000  
  19.                 </sonar.host.url>  
  20.             </properties>  
  21.         </profile>  
  22.      </profiles>  
  23. </settings>  
  • 在pom.xml所在目录运行maven命令:
[plain]  view plain  copy
  在CODE上查看代码片 派生到我的代码片
  1. mvn clean install  
  2. mvn sonar:sonar  

使用Ecplise插件:

  • 安装,插件地址:http://dist.sonar-ide.codehaus.org/eclipse/ 
  • 设置插件参数,配置sonar服务器地址:


  • 将本地项目与sonar平台关联:


  • 右键检查代码质量:
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值