Maven项目中配置使用SonarQube

1、配置 maven 全局配置

在 apache-maven/conf/settings.xml 中配置如下内容:

<settings>
    <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://test.com
                </sonar.host.url>
            </properties>
        </profile>
     </profiles>
</settings>

2、使用命令对代码进行分析

# 分析代码命令
mvn sonar:sonar
# 可以和打包、编译、安装等命令一起使用,例如:
mvn clean package sonar:sonar

3、使用命令将项目发送到指定地址进行分析

mvn sonar:sonar -Dsonar.host.url=http://test.com

results matching ""

    No results matching ""