sonar使用記錄

Sonar簡介

 

Sonar是一個用於代碼質量管理的開源平臺,用於管理源代碼的質量,可以從七個維度檢測代碼質量

通過插件形式,可以支持包括java,C#,C/C++,PL/SQL,Cobol,JavaScrip,Groovy等等二十幾種編程語言的代碼質量管理與檢測

Sonar 安裝

環境準備:

1、Java環境 1.6以上

2、數據庫環境,我這裏選擇的是mysql,實際上也可以完全不需要數據庫就能運行,因爲Sonar內置了缺省數據庫

下載Sonar

直接到D:\sonarqube-5.1\bin路徑下進行啓動,裏面有多個版本的啓動方式

 因爲我這裏用的windows64位,所以選擇windows64位進行啓動,在啓動之前需要修改sonar.properties配置文件,把數據庫修改成mysql的,具體修改項如下

sonar.jdbc.username=*****
sonar.jdbc.password=******

sonar.jdbc.url=jdbc:mysql://localhost:3306/sonarqube?useUnicode=true&characterEncoding=utf8&rewriteBatchedStatements=true&useConfigs=maxPerformance

 

其他的都是選擇該的值,比如

#----- Connection pool settings
# The maximum number of active connections that can be allocated
# at the same time, or negative for no limit.
sonar.jdbc.maxActive=50

# The maximum number of connections that can remain idle in the
# pool, without extra ones being released, or negative for no limit.
sonar.jdbc.maxIdle=5

# The minimum number of connections that can remain idle in the pool,
# without extra ones being created, or zero to create none.
sonar.jdbc.minIdle=2

# The maximum number of milliseconds that the pool will wait (when there
# are no available connections) for a connection to be returned before
# throwing an exception, or <= 0 to wait indefinitely.
sonar.jdbc.maxWait=5000

sonar.jdbc.minEvictableIdleTimeMillis=600000
sonar.jdbc.timeBetweenEvictionRunsMillis=30000

 

 

這個時候還是不能啓動,因爲mysql數據庫中還是沒有sonarqube這個數據庫呢

 

需要在mysql中執行如下語句

mysql> CREATE DATABASE sonar CHARACTER SET utf8 COLLATE utf8_general_ci; 
mysql> CREATE USER 'sonar' IDENTIFIED BY 'sonar';
mysql> GRANT ALL ON sonar.* TO 'sonar'@'%' IDENTIFIED BY 'sonar';
mysql> GRANT ALL ON sonar.* TO 'sonar'@'localhost' IDENTIFIED BY 'sonar';
mysql> FLUSH PRIVILEGES;

 

這樣就可以啓動了,啓動完成以後界面如下

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章