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&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
如果报错,在pom文件里加上
<plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>sonar-maven-plugin</artifactId> <version>2.6</version></plugin>
原文地址:https://www.cnblogs.com/yangxianyu/p/8536906.html
时间: 2024-10-08 15:55:02