SonarQube静态代码分析maven集成方式

1.在maven的setting.xml增加如下配置

<profile>
        <id>sonar</id>
        <activation>
            <activeByDefault>true</activeByDefault>
        </activation>
        <properties>
            <sonar.jdbc.url>jdbc:mysql://10.10.13.7:3306/sonar?useUnicode=true&amp;characterEncoding=utf8</sonar.jdbc.url>   
            <sonar.jdbc.driver>com.mysql.jdbc.Driver</sonar.jdbc.driver>
            <sonar.jdbc.username>devuser</sonar.jdbc.username>
            <sonar.jdbc.password>devuser</sonar.jdbc.password>
                        <sonar.host.url>http://10.10.13.11:9000/sonar</sonar.host.url> 
                    <!-- Sonar服务器访问地址 -->
        </properties>
 </profile>

<activeProfiles>
    <activeProfile>sonar</activeProfile>
</activeProfiles>

2.在项目目录下执行mvn sonar:sonar

执行成功后打开http://10.10.13.11:9000/sonar

如果报错

java.lang.TypeNotPresentException: Type org.sonarsource.scanner.maven.SonarQubeMojo not present

在pom文件里加上

<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>sonar-maven-plugin</artifactId>
<version>2.6</version>
</plugin>

 

posted @ 2018-03-09 23:02  Nice&&Day  阅读(634)  评论(0编辑  收藏  举报