Environmental preparation
1. SonarQube download: https://www.sonarqube.org/downloads/
It is recommended to use the latest version . The combination of SonarQube and idea requires a lot of SonarQube plugins, and the SonarLint plugin of idea is needed.
Different SonarQube versions have different plug-in versions
Idea’s SonarLint plug-in version, requires a different SonarQube plug-in version
To successfully issue the report, you need:
The SonarLint version of idea corresponds to the plug-in version of SonarQube one-to-one
2. Java 11 or above installation
If there are multiple versions of JDK, please refer to the way to switch the operating environment:
https://zengmiaogen.blog.csdn.net/article/details/106472790
3.PostgreSQL 9.3 or greater
Optional, if you just use it yourself, you don’t need to install it
installation steps
SonarQube installation
Unzip and enter D:\sonarqube-8.3.1.34397\bin\windows-x86-64\ StartSonar.bat
Browser access: http://localhost:9000/
Default account password: admin admin
Configure Chinese interface
After login
After the installation is successful, restart SonarQube
Chinese interface
SonarLint installation
idea--plugins
If you can’t download it, follow the official account at the end of the article, reply to sonar, get the plug-in installation package, and idea chooses to install the plug-in from disk
SonarLint configuration
Connect to Sonarcode service
Write the name casually, click to generate
Project configuration SonarQube maven plugin
Add to the root directory pom.xml of the MAVEN project
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.sonarsource.scanner.maven</groupId>
<artifactId>sonar-maven-plugin</artifactId>
<version>3.7.0.1746</version>
</plugin>
</plugins>
</pluginManagement>
</build>
After the maven dependency is loaded, the sonar plugin will appear in the maven of idea
Clean first, then compile, and finally double-click "sonar:sonar" and wait for the end of the run
View report
------------------------------