一、安装并配置好JDK
根据soanr版本的不同,对JDK的版本要求不同,这个可以在sonar的官网看到,我这次安装的是jdk8;
二、安装并配置好数据库
我选择的是mysql数据库
#创建数据库sonar
mysql>CREATE DATABASE sonar CHARACTER SET utf8 COLLATE utf8_general_ci;
#创建用户sonar
mysql>CREATE USER 'sonar' IDENTIFIED BY '<password you picked>';
#设置权限
mysql>GRANT ALL ON sonar.* TO 'sonar'@'%' IDENTIFIED BY '<password you picked>';
mysql>GRANT ALL ON sonar.* TO 'sonar'@'localhost' IDENTIFIED BY '<password you picked>';
mysql>FLUSH PRIVILEGES;
三、从官网下载sonarqube,并解压到c盘根目录
四、配置sonarqube与mysql数据库的连接
打开C:\sonarqube-7.2.1\conf目录下的sonar.properties文件,找到mysql部分,设置好sonar.jdbc.url:
#----- MySQL >=5.6 && <8.0
# Support of MySQL is dropped in Data Center Editions and deprecated in all other editions
# Only InnoDB storage engine is supported (not myISAM).
# Only the bundled driver is supported. It can not be changed.
#sonar.jdbc.url=jdbc:mysql://localhost:3306/sonar?
sonar.jdbc.url=jdbc:mysql://localhost:3306/sonar?useUnicode=true&characterEncoding=utf8&rewriteBatchedStatements=true&useConfigs=maxPerformance
sonar.jdbc.username=sonar #sonar是在mysql中新建的数据库
sonar.jdbc.password=‘’<password you picked>’
sonar.sorceEncoding=UTF-8
sonar.login=admin
sonar.password=admin
url是数据库连接地址,username是数据库用户名,jdbc.password是数据库密码,login是sonarqube的登录名,sonar.password是sonarqube的密码
五、启动sonarqube ,进入系统,连接数据较慢,需要等待一段时间才能完全启动成功
六、安装中文插件
Administration->Marketplace->Plugins,搜索“chinese pack”,安装