版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/Amelia__Liu/article/details/84631257
1.idea安装插件
sonarLint
安装好后重启idea
2.在maven的setting.xml中增加:
<profile>
<id>sonar</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<properties>
<sonar.host.url>http://10.20.5.181:9000</sonar.host.url>
</properties>
</profile>
3.在项目的pom.xml增加
<plugin>
<groupId>org.sonarsource.scanner.maven</groupId>
<artifactId>sonar-maven-plugin</artifactId>
<version>3.3.0.603</version>
</plugin>
4.idea设置中那个地址也就是sonar集成好的环境吧
5.
org.sonarsource.scanner.maven:sonar-maven-plugin:3.3.0.603:sonar
将jdk设置为1.8
6.运行这个sonar
7.如果报错:
File src/test/java/com/web/Test.java can't be indexed twice. Please check that inclusion/exclusion patterns produce disjoint sets for main and test files
则在maven的setting.xml也就是刚刚新加的地方新增:
<sonar.sources>src/main</sonar.sources>
<sonar.tests>src/test</sonar.tests>