brew的下载安装:https://www.jianshu.com/p/b7b789a2ed2c
前提是JDK和数据库都已经安装配置好。
Mac下JDK的下载安装、配置:https://www.jianshu.com/p/7a48536bfea9
sonarqube安装
1.命令行输入:
brew install sonarqube
官网下载地址:https://www.sonarqube.org/downloads/
配置
2.环境变量的设置
(1)进入配置文件
cd /usr/local/Cellar/sonarqube/8.4.1.35646/libexec/conf
(2)修改配置文件
vim sonar.properties
sonar.jdbc.url=jdbc:mysql://localhost:3306/sonar?useUnicode=true&characterEncoding=utf8&rewriteBatchedStatements=true
(3)修改jdk的配置:
vim wrapper.conf
为什么需要修改呢?因为发现启动了sonarqube,浏览器无法打开,排查日志,发现需要jdk11以上。
启动
3.SonarQube的启动
命令行:cd /usr/local/Cellar/sonarqube/8.4.1.35646/bin
启动:./sonar start
暂停:./sonar stop
重启:./sonar restart
4.浏览区访问
浏览器输入http://localhost:9000,登录SonarQube,
输入账户admin和密码 admin
中文设置:
Soanr-scanner安装
5.Soanr-scanner安装:https://www.jianshu.com/p/be42bc3203a3
6.到要检查的代码根目录下创建文件sonar-project.properties
# must be unique in a given SonarQube instance
sonar.projectKey=study
# this is the name and version displayed in the SonarQube UI. Was mandatory prior to SonarQube 6.1.
sonar.projectName=study
sonar.projectVersion=1.0
# Path is relative to the sonar-project.properties file. Replace "\" by "/" on Windows.
# This property is optional if sonar.modules is set.
sonar.sources=./src
sonar.java.binaries=./target/classes
sonar.language=java
# Encoding of the source code. Default is default system encoding
#sonar.sourceEncoding=UTF-8
7.命令行到要检查的代码目录下,输入命令:sonar-scanner
检查的结果直接可以在浏览器SonarQube上查看
网友评论