sonar 简单安装,配置,以及使用

服务端启动配置

1.下载sonarqube-5.1.zip server包
http://downloads.sonarsource.com/sonarqube/sonarqube-5.1.zip

2.安装mysql 服务端
并创建sonar用户,sonar数据库
#mysql -u root -p   
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

3.修改sonarconfig文件
/Users/dengkui/soft_install/sonarqube-5.1/conf/sonar.properties

sonar.jdbc.url=jdbc:mysql://localhost:3306/sonar?useUnicode=true&characterEncoding=utf8&rewriteBatchedStatements=true&useConfigs=maxPerformance
sonar.jdbc.driverClassName=com.mysql.jdbc.Driver
sonar.jdbc.username=sonar
sonar.jdbc.password=sonar

4. sonar web port 修改,以防端口冲突
sonar.web.port=9999

5.启动sonar服务器
cd /Users/dengkui/soft_install/sonarqube-5.1/bin/macosx-universal-64
./sonar.sh start

6.验证sonar是否正常启动
http://localhost:9999 查看页面是否能正常打开


客户端链接配置
1. 打开Eclipse MarkPlace,输入sonar,并安装

2. 配置SonarQube 插件,打开Perference,找到SonarQube--servers
   新建server地址
   ID:localhost
   Server Url:http://localhost:9999
   username:admin
   password:admin

   点击test connection,按照eclipse提示操作,直到提示successfully connected

3.新建maven项目,选中项目右键--Configure--Associate with SonarQube


4. 修改 settings.xml
 <profile>
   <id>sonar</id>
    <activation>
     <activeByDefault>true</activeByDefault>
    </activation>
    <properties>
    <sonar.jdbc.url>jdbc:mysql://localhost:3306/sonar?useUnicode=true&amp;characterEncoding=utf8&amp;rewriteBatchedStatements=true&amp;useConfigs=maxPerformance</sonar.jdbc.url>
    <sonar.jdbc.driver>com.mysql.jdbc.Driver</sonar.jdbc.driver>
    <sonar.jdbc.username>sonar</sonar.jdbc.username>
    <sonar.jdbc.password>sonar</sonar.jdbc.password>
    <sonar.host.url>http://localhost:9999</sonar.host.url>
    </properties> 
 </profile> 

 5. 选中新建项目右键--Run as --Run Configrations,Goals项填写:sonar:sonar -X
 如果发布成功,那么现在你可以去http://localhost:9999,这里查看你刚发布的项目,想做分析还是干吗都可以在这里处理了

相关推荐