Sonar无法连接到数据库

She*_*naz 7 sonarqube

我使用以下软件:

  • 声纳3.4.1
  • Mysql 5.1
  • Maven 2.2.1
  • 雄猫7

我有一个pom.xml文件,我试图用Sonar执行但是得到了以下错误.

[INFO] Building asgard-bpm
[INFO] task-segment: [sonar:sonar] (aggregator-style)
[INFO] -----------------------------------------------------------------------
[INFO] [sonar:sonar {execution: default-cli}]
[INFO] Sonar host: http://{host:8080}/sonar
[INFO] Sonar version: 3.4.1
[INFO] Execute: org.codehaus.sonar:sonar-maven-plugin:3.4.1:sonar
[INFO] [sonar:sonar {execution: default-sonar}]
[INFO] [14:34:54.474] Load project settings
[INFO] [14:34:54.552] Install plugins
[INFO] [14:34:56.674] Apply project exclusions
[INFO] [14:34:56.674] Install JDBC driver
[WARN] [14:34:56.736] H2 database should be used for evaluation purpose only
[INFO] [14:34:56.736] Create JDBC datasource for jdbc:h2:tcp://host/sonar
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] Can not execute Sonar

Embedded error: Fail to connect to database
Connection refused: connect
Run Code Online (Sandbox Code Playgroud)

我在DB中创建了一个用户名为'sonar'且密码为'sonarsonar'的用户.

创建名为"sonar"的模式,并授予所有权限.

以下是SONAR.properties文件中设置的属性.

sonar.web.host:                           {127.0.0.1}
sonar.web.port:                           80
sonar.web.context:                        /


sonar.jdbc.username:                       sonar
sonar.jdbc.password:                       sonarsonar

sonar.jdbc.url:                                      {jdbc:mysql://host:3306/sonaruseUnicode=true&characterEncoding=utf8}
sonar.jdbc.driverClassName:                com.mysql.jdbc.Driver
sonar.jdbc.validationQuery:                select 1
Run Code Online (Sandbox Code Playgroud)

有人可以告诉我如何解决此错误.

Cha*_* SB 5

您的声纳未连接到您的数据库。检查您的 < .m2/settings.xml > 文件。您需要更改属性下的 <sonar.jdbc.url>:

<!-- H2 - Default DB -->
<!-- <sonar.jdbc.url>
       jdbc:h2:tcp://localhost:9092/sonar
     </sonar.jdbc.url> -->
<!-- MySQL DB -->
    <sonar.jdbc.url>
      jdbc:mysql://localhost:3306/sonar?useUnicode=true&amp;characterEncoding=utf8
    </sonar.jdbc.url>
Run Code Online (Sandbox Code Playgroud)