Installation and use of sonar

installation

1. Download from the official website, https://www.sonarqube.org/downloads/

2. Download the requirements to be optimistic before, I installed version 7.6, the requirement is jdk1.8, mysql 5.6 to 8 and I'm using 5.7

3. After downloading extract it, run different bin "windows-x86-64" StartSonar.bat different operating systems. Access localhost: 9000, can see the page, it means that the environment is no problem. Otherwise it will enhance the jdk the wrong version.

4. conf "sonar.properties, the following configuration is added, and then perform 3. Remember to delete the comment. If you start logging error, you can know all the java process in Task Manager, and then start.

If you start to, in the newly built data, the table will be generated.

= jdbc sonar.jdbc.url: MySQL: // localhost: 3306 / = to true sonarqube useUnicode & characterEncoding = utf8 & rewriteBatchedStatements to true & useConfigs = = = maxPerformance & useSSL false? 
sonar.jdbc.username = username   // sonarqube user just created 
sonar.jdbc.password = password    // create a user password corresponding 
sonar.sorceEncoding = UTF-8 // set is UTF-8 encoding format

5. Access http: // localhost: 9000  default account password is admin

 

Install Chinese

Download: https://github.com/SonarQubeCommunity/sonar-l10n-zh

1. extensions 》 plugins

As shown below, click to download, then wait for the installation is complete restart.

 

Installation sonar-scanner

Download: https://docs.sonarqube.org/latest/analysis/scan/sonarscanner/

Extract from the bin directory to the path, in cmd performed sonar-scanner -v, you can have a log output.

 

Use a

On the sonar page, build the project, I use the java, built with the maven

 

Use two

Using sonar-scanner to scan

1. Create a new file in the project sonar-project.properties

# must be unique in a given SonarQube instance
sonar.projectKey=demo1
# this is the name and version displayed in the SonarQube UI. Was mandatory prior to SonarQube 6.1.
sonar.projectName=demo1
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. 
# Encoding of the source code. Default is default system encoding
#sonar.sourceEncoding=UTF-8

sonar.login=39aff716f3014a7d341f6eae2ac4aec8887b9ce7
sonar.sources=src

Sonar.projectKey # = Key projects (custom)
Sonar.projectName # = Project Name
Sonar.projectVersion # = Project version
Sonar.sources # = Project Path
# Add the following line
sonar.java.binaries=./target/classes

# Checks only java files
sonar.inclusions=src/main/java/com/demo/**/*.java

2. Run the sonar-scanner.bat -Dsonar.login = 39aff716f3014a7d341f6eae2ac4aec8887b9ce7 -Dsonar.java.binaries =. / Target / classes, to the implementation of the project directory.

 

Executed, will generate test report

 

The second personal feel convenient.

 

References:

sonar configuration: https://blog.csdn.net/weixin_40861707/article/details/82117232

scan configuration: https://my.oschina.net/guiguketang/blog/1814985

Guess you like

Origin www.cnblogs.com/amibandoufu/p/11716272.html