<settings>
<pluginGroups>
<pluginGroup>org.sonarsource.scanner.maven</pluginGroup>
</pluginGroups>
<profiles>
<profile>
<id>sonar</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<properties>
<!-- Optional URL to server. Default value is http://localhost:9000 -->
<sonar.host.url>
http://myserver:9000
</sonar.host.url>
<!--
<sonar.inclusions>
src/main/java/com/elmsc/lnddwjs/**
</sonar.inclusions>
<sonar.exclusions>
src/main/java/com/demo/sap1/**,
src/main/java/com/demo/sap2/**
</sonar.exclusions>
-->
</properties>
</profile>
</profiles>
</settings>
<plugin>
<groupId>org.sonarsource.scanner.maven</groupId>
<artifactId>sonar-maven-plugin</artifactId>
<version>3.4.0.905</version>
</plugin>
方式二:
# In some situation you may want to run sonar:sonar goal as a dedicated step. Be sure to use install as first step for multi-module projects
mvn clean install
mvn sonar:sonar