sonarLint 与 IntelliJ IDEA 集成
SonarQube 下载https://www.sonarqube.org/downloads/
一.安装 SonarQube
将来下载的 SonarQube 解压打开 bin 目录,启动相应 OS 目录下的 StartSonar。使用的是 win 的 32 位系统,则打开 D:\sonarqube-5.6.6\sonarqube-5.6.6\bin\windows-x86-32\StartSonar.bat
启动浏览器访问 http://localhost:9000 出现 sonarqube 界面则说明安转成功

sonarqube
二、配置
1、1.打开 mysql,新建一个数据库。

mysql
2、打开 sonarqube 安装目录下的 D:\sonarqube-5.6.6\sonarqube-5.6.6\conf\sonar.properties 文件
再 mysql5.6 下添加
sonar.jdbc.url=jdbc:mysql://localhost:3306/sonar?useUnicode=true&characterEncoding=utf8&rewriteBatchedStatements=true&useConfigs=maxPerformance
sonar.jdbc.username=root
sonar.jdbc.password=***
sonar.sorceEncoding=UTF-8
sonar.login=admin
sonar.password=admin
4.重启 sonarqube 服务,再次访问 http://localhost:9000,会稍微有点慢,因为要初始化数据库信息
5.数据库初始化成功后,登录
6.进入插件安装页面

chinese pack
7、chinese pack 安装成功后重启服务。
三、Connected Mode
1、file->setting->other setting 配置 sonarqube servers

sonarqube servers
2、test connect error

connection
3、更新 sonarjava 跟 sonarjs

update
4、新建项目


正在上传...取消
5、绑定 idea 项目至 sonaerqube 项目

bing project
6、执行。
执行后在 idea 的控制台可以看到 sonar lint 的结果。但是在服务器上无法看到结果???
四、通过 maven 来执行
1、配置 maven
pom.xml
<plugin>
<groupId>org.sonarsource.scanner.maven</groupId>
<artifactId>sonar-maven-plugin</artifactId>
<version>3.2</version>
</plugin>
<plugin>
setting.xml
<profiles>
<profile>
<id>sonar</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<properties>
<sonar.jdbc.url>jdbc:mysql://localhost:3306/sonar</sonar.jdbc.url>
<sonar.jdbc.driver>com.mysql.jdbc.Driver</sonar.jdbc.driver>
<sonar.jdbc.username>root</sonar.jdbc.username>
<sonar.jdbc.password>jkzl123456</sonar.jdbc.password>
<sonar.host.url>http://localhost:9000</sonar.host.url>
</properties>
</profile>
</profiles>
<pluginGroups>
<pluginGroup>org.sonarsource.scanner.maven</pluginGroup>
</pluginGroups>
2、控制台执行 mvn clean install ,mvn sonar:sonar
3、打开 localhost:9000

maven webapp
版权声明: 本文为 InfoQ 作者【夏兮。】的原创文章。
原文链接:【http://xie.infoq.cn/article/648bcaa2490f31545abd027a7】。
本文遵守【CC BY-NC】协议,转载请保留原文出处及本版权声明。
评论