我正在尝试针对我的代码库运行Sonar代码质量并获得以下异常。我已成功安装Sonar服务器,http://gsi-547576:9900将主页返回给我,没有任何问题。我没有将Sonar连接到任何外部数据库,并且当前使用默认的内存数据库。
用于运行声纳的命令:
mvn clean install -Psonar sonar:sonar
错误日志:
[INFO] SonarQube version: 5.0
INFO: Default locale: "en_US", source code encoding: "UTF-8"
INFO: Work directory: C:\nital\my-pet-projects\istore\istore-mvc2\istore-mvc2-domain\target\sonar
INFO: SonarQube Server 5.0
[INFO] [11:21:11.716] Load global referentials...
[INFO] [11:21:11.916] Load global referentials done: 200 ms
[INFO] [11:21:11.916] User cache: C:\Users\chandeln\.sonar\cache
[INFO] [11:21:11.926] Install plugins
[INFO] [11:21:11.966] Install JDBC driver
[INFO] [11:21:11.976] Create JDBC datasource for jdbc:h2:tcp://localhost/sonar
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 7.576 s
[INFO] Finished at: 2015-05-04T11:21:14-04:00
[INFO] Final Memory: 23M/224M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.codehaus.mojo:sonar-maven-plugin:2.6:sonar (default-cli) on project istore-mvc2-domain: Fail to connect to database: Cannot create PoolableConnectionFactory (Co
nnection is broken: "java.net.ConnectException: Connection refused: connect: localhost" [90067-176]) -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
的settings.xml
<profile>
<id>sonar</id>
<properties>
<sonar.host.url>http://gsi-547576:9900/</sonar.host.url>
</properties>
</profile>
的pom.xml
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.istore</groupId>
<artifactId>istore-mvc2-domain</artifactId>
<version>1.2-SNAPSHOT</version>
<packaging>jar</packaging>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.7</maven.compiler.source>
<maven.compiler.target>1.7</maven.compiler.target>
</properties>
<scm>
<connection>scm:svn:https://gsi-547576/svn/istore/istore-mvc2-domain/trunk</connection>
<developerConnection>scm:svn:https://gsi-547576/svn/istore/istore-mvc2-domain/trunk</developerConnection>
<url>https://gsi-547576/svn/istore/istore-mvc2-domain/trunk</url>
</scm>
<build>
<finalName>${project.artifactId}</finalName>
<plugins>
<!-- Releasing a project -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
<version>2.5.1</version>
<configuration>
<tagBase>https://gsi-547576/svn/istore/istore-mvc2-domain/tags</tagBase>
</configuration>
</plugin>
</plugins>
</build>
<!-- For deploying the artifacts to Nexus -->
<distributionManagement>
<snapshotRepository>
<id>my-nexus-server</id>
<name>Internal Snapshots</name>
<url>http://gsi-547576:8081/nexus/content/repositories/snapshots</url>
</snapshotRepository>
<repository>
<id>my-nexus-server</id>
<name>Internal Releases</name>
<url>http://gsi-547576:8081/nexus/content/repositories/releases</url>
</repository>
</distributionManagement>
</project>
答案 0 :(得分:0)
您的日志表明您遇到了与数据库建立连接的问题,这看起来很合理,因为您似乎没有使用支持的数据库http://docs.sonarqube.org/display/SONAR/Requirements#Requirements-SupportedPlatforms
您是否尝试在intall之后和运行分析之前打开SonarQube?
答案 1 :(得分:0)
修改m2 settings.xml后,它工作了:)我更新的settings.xml文件
<强> 2 / settings.xml中强>
<profiles>
<profile>
<id>sonar</id>
<activation>
<activeByDefault>false</activeByDefault>
</activation>
<properties>
<sonar.host.url>http://gsi-547576:9900</sonar.host.url>
<sonar.jdbc.url>jdbc:h2:tcp://gsi-547576:9092/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>
</properties>
</profile>
</profiles>