Sonar是开源的代码质量管理平台,它把代码质量相关软件集成到一起统一管理,集成的软件如下:
CPD
Checkstyle
Clover
Cobertura
Findbugs
General
Google analytics
PMD
Squid
Surefire
我把安装过程记录下来.
1.环境准备如下
redhat6
jdk1
.7
mysql5以上
2.下载Sonar,到http://sonar.codehaus.org/下载最新版本,我下载的是sonar-3.6.1.zip,下载后解压即可
unzip sonar-3.6.1.zip
3.数据库配置
CREATE
DATABASE
sonar
CHARACTER
SET
utf8 COLLATE utf8_general_ci;
grant
all
on
sonar.
*
to
sonar@
'
%
'
identified
by
'
sonar
'
;
grant
all
on
sonar.
*
to
sonar
@localhost
identified
by
'
sonar
'
;
flush
privileges
;
官方没有grant all on sonar.* to sonar@'%' identified by 'sonar'; 如果你想远程发布项目到sonar,那就需要加上这条。
注:其实这个执行脚本本身sonar就提供了,如图所示:
然后还要更改sonar的配置,在sonar的解压目录下打开conf/sonar.properties,注掉如下内容(如果你没有mysql就可以不改动这个文件,sonar默认使用内嵌数据库derby)
#sonar.jdbc.url: jdbc:derby://localhost:
1527
/sonar
;
create=true
#sonar.jdbc.driverClassName: org.apache.derby.jdbc.ClientDriver
#sonar.jdbc.validationQuery: values(
1
)
去掉下面的注释
sonar.jdbc.url: jdbc:mysql://
192.168.1.***
:
3306
/sonar?useUnicode
=
true&characterEncoding
=
utf8
sonar.jdbc.driverClassName: com.mysql.jdbc.Driver
sonar.jdbc.validationQuery: select
1
Ok,配置已经完成你可以在bin目录项下进入相应平台的子目录,比如我的就是${sonar_home}bin/linux-x86-64,sonar是多平台的,你可以在bin目录下查找你对应的平台,然后执行
${sonar_home}bin
/
linux
-
x86
-
64
/
sonar
.
sh start
这里面我使用的是64位redhat。
启动后访问http://localhost:9000就可以进入sonar了, 默认管理员用户和密码是admin/admin。
![Sonar的安装_第1张图片](http://img.e-com-net.com/image/info5/92f7764bf2ff4b7db8e69167b2c70ece.jpg)