【问题标题】:Cannot load JDBC driver class 'com.mysql.jdbc.Driver' sonar plugin jenkins无法加载 JDBC 驱动程序类“com.mysql.jdbc.Driver”声纳插件詹金斯
【发布时间】:2014-07-01 05:27:06
【问题描述】:

我正在使用带有 jenkins 的声纳插件。它总是会产生这个错误。插件似乎找不到 JDBC 驱动程序。根据我在google上找到的许多解决方案,我尝试将JDBC驱动程序放在许多可能的地方,但它仍然会产生这个错误。

C:\Jenkins\tools\hudson.plugins.sonar.SonarRunnerInstallation\sonar-runner-2.4
SonarQube Runner 2.4
Java 1.7.0_21 Oracle Corporation (32-bit)
Windows Server 2008 R2 6.1 x86
INFO: Runner configuration file: C:\Jenkins\tools\hudson.plugins.sonar.SonarRunnerInstallation\sonar-runner-2.4\conf\sonar-  runner.properties
INFO: Project configuration file: C:\Jenkins\jobs\check2\workspace\sonar-   project.properties
INFO: SonarQube Server 4.3.2
10:18:10.612 INFO  - Load batch settings
10:18:14.265 INFO  - User cache: C:\.sonar\cache
10:18:14.321 INFO  - Install plugins
10:18:18.941 INFO  - Install JDBC driver
10:18:18.971 INFO  - Create JDBC datasource for jdbc:mysql://localhost:3306/sonar
INFO: ------------------------------------------------------------------------
INFO: EXECUTION FAILURE
INFO: ------------------------------------------------------------------------
Total time: 22.884s
Final Memory: 3M/15M
INFO: ------------------------------------------------------------------------
ERROR: Error during Sonar runner execution
ERROR: Unable to execute Sonar
ERROR: Caused by: Fail to connect to database
ERROR: Caused by: Cannot load JDBC driver class 'com.mysql.jdbc.Driver'
ERROR: Caused by: com.mysql.jdbc.Driver
ERROR: 
ERROR: To see the full stack trace of the errors, re-run SonarQube Runner with the -e switch.
ERROR: Re-run SonarQube Runner using the -X switch to enable full debug logging.
Build step 'Invoke Standalone Sonar Analysis' marked build as failure
Finished: FAILURE    

【问题讨论】:

  • 您是否在项目中添加了所需的 jar 文件?
  • 您在问题中说您“尝试将 JDBC 驱动程序放在许多可能的地方”。 JDBC 驱动程序是一个 jar 文件。
  • 对不起。是的,它在项目中
  • 请发布您的 jenkins-sonar-plugin 配置内容和配置数据库的 sonar/conf/sonar.properties 的内容。您可能错过了 2 个之一的正确配置。
  • 我搜索的是从哪里声纳插件试图找到 JDBC 库?来自我们的项目还是来自它的库?

标签: jdbc jenkins jenkins-plugins sonarqube


【解决方案1】:

我发现了问题。它位于 sonar/conf/sonar.properties 文件中(在 sonarqube 安装文件夹中)。数据库的默认 url 错误。我为mysql纠正了它。现在它工作正常。我花了几天的时间。感谢 TimHauschildt 和 SKempken。

【讨论】:

  • 这很奇怪。我认为它会从我的 maven settings.xml 文件中提取它。感谢您解决这个问题。
  • ...另外,不要像我一样愚蠢,在更改这些属性后忘记重新启动 SonarQube。 ;-)(SonarQube 5.1 默认使用 H2,当运行定义它使用 MySQL 的 Gradle 构建时确实会引发上述错误。)
猜你喜欢
  • 2016-08-18
  • 2012-04-23
  • 2012-08-24
  • 1970-01-01
  • 1970-01-01
  • 2017-03-10
  • 2016-02-15
  • 2013-05-10
  • 2016-07-07
相关资源
最近更新 更多