1、jdk1.8 mysql5.6(以上) 2、下载sonarqube http://www.sonarqube.org/downloads/ 2.1、解压,修改配置文件sonarqube-*\conf\sonar.properties sonar.login=admin sonar.password=admin sonar.jdbc.url=jdbc:mysql://localhost:3306/sonar?useUnicode=true&characterEncoding=utf8&rewriteBatchedStatements=true&useConfigs=maxPerformance sonar.jdbc.username=root sonar.jdbc.password=123456 sonar.sorceEncoding=UTF-8 2.2、启动 a、进入sonarqube-*/bin/ b、./sonar.sh start 2.3、登陆 http://localhost:9000 administrator --> System --> Update center --> avaliable --> 汉化包 3、下载sonar runner安装包 https://sonarsource.bintray.com/Distribution/sonar-scanner-cli/ 3.1、解压,修改配置文件sonar-scanner-*\conf\sonar-runner.properties sonar.host.url=http://localhost:9000 sonar.jdbc.url=jdbc:mysql://172.16.30.228:3306/qjfsonar?useUnicode=true&characterEncoding=utf8&rewriteBatchedStatements=true&useConfigs=maxPerformance sonar.jdbc.username=gmsd sonar.jdbc.password=gmsdtrade 4、分析,环境变量(略) sonar-runner -version 4.1打开要进行代码分析的项目根目录,新建sonar-project.properties文件 # must be unique in a given SonarQube instance sonar.projectKey=my:apiautocore # this is the name displayed in the SonarQube UI sonar.projectName=apiautocore(项目名字) sonar.projectVersion=1.0 # Path is relative to the sonar-project.properties file. Replace "\" by "/" on Windows. # Since SonarQube 4.2, this property is optional if sonar.modules is set. # If not set, SonarQube starts looking for source code from the directory containing # the sonar-project.properties file. #sources是源文件所在的目录 sonar.sources=src sonar.binaries=WebRoot/WEB-INF/classes # Encoding of the source code. Default is default system encoding sonar.language=java sonar.my.property=value #sonar.sourceEncoding=UTF-8 4.2、启动sonarqube服务,在cmd进入项目所在的根目录,输入命令:sonar-runner 5、看结果 打开http://localhost:9000/
时间: 2024-10-14 01:46:13