1. Sonar 拷到目标位置:sonar-2.12http://sonar.codehaus.org/downloads/(官方网站下载的最新版本)
2. 在E:\Program Files\sonar-2.12\bin\windows-x86-32 点击InstallNTService.bat,安装服务(默认会成为automated 的serice 服务,服务名:sonar);
3. StartNTService.bat启动服务
4. StartSonar.bat 启动 sonar(安装服务以后,只需要在服务中启动就可以了。)
集成到maven:
配置与maven2的关联(默认是localhost:9000,使用默认不修改也可以)
在$MAVEN_HOME/conf(如D:\apache-maven-2.0.9\conf)或者~/.m2下的settings.xml文件加入下面内容
<profile>
<id>sonar</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<properties>
<sonar.jdbc.url>
jdbc:derby://localhost:1527/sonar
</sonar.jdbc.url>
<sonar.jdbc.driver>org.apache.derby.jdbc.ClientDriver</sonar.jdbc.driver>
<sonar.jdbc.username>sonar</sonar.jdbc.username>
<sonar.jdbc.password>sonar</sonar.jdbc.password>
<sonar.host.url>http://127.0.0.1:9000/</sonar.host.url>
</properties>
</profile>
缺省用户名密码:admin/admin
未验证内容:
在WEB页面上创建DB,创建后可以看到D:\sonar-1.4.3\conf\sonar.properties
sonar.jdbc.url: jdbc:derby://localhost:1527/sonar;create=true
sonar.jdbc.driverClassName: org.apache.derby.jdbc.ClientDriver
3. pom.xml 中添加插件内容:
<plugin>
<groupId>org.codehaus.sonar</groupId>
<artifactId>sonar-maven-plugin</artifactId>
<version>1.8</version>
</plugin>
启动:mvn sonar:sonar