简体   繁体   English

NoSuchMethodError: com.zaxxer.hikari.HikariDataSource.getMetricsTrackerFactory()Lcom/zaxxer/hikari/metrics/MetricsTrackerFactory

[英]NoSuchMethodError: com.zaxxer.hikari.HikariDataSource.getMetricsTrackerFactory()Lcom/zaxxer/hikari/metrics/MetricsTrackerFactory

I'm migrating a Java Spring application to Spring Boot.我正在将 Java Spring 应用程序迁移到 Spring Boot。 I've transferred the application-context.xml configuration inside Java beans.我已经将 application-context.xml 配置转移到 Java beans 中。 However, when I try to launch the Spring Boot app, I get the following error:但是,当我尝试启动 Spring Boot 应用程序时,出现以下错误:

java.lang.NoSuchMethodError: com.zaxxer.hikari.HikariDataSource.getMetricsTrackerFactory()Lcom/zaxxer/hikari/metrics/MetricsTrackerFactory; java.lang.NoSuchMethodError: com.zaxxer.hikari.HikariDataSource.getMetricsTrackerFactory()Lcom/zaxxer/hikari/metrics/MetricsTrackerFactory;

It seems like there is something wrong with my configuration or the library version I'm using, but so far I've no clue.似乎我的配置或我正在使用的库版本有问题,但到目前为止我还没有任何线索。 I'm using Spring Boot 2.5.6 and HikariCP 2.5.1.我正在使用 Spring Boot 2.5.6 和 HikariCP 2.5.1。

Here is my data source configuration:这是我的数据源配置:

@Primary
@Bean(destroyMethod = "close")
DataSource dataSource(DatasourceProperties datasourceProperties) {
     return DataSourceBuilder.create()
          .type(HikariDataSource.class)
          .driverClassName(datasourceProperties.getDriverClassName())
          .url(datasourceProperties.getUrl())
          .username(datasourceProperties.getUsername())
          .password(datasourceProperties.getPassword())
          .build();
}

I can provide more configuration and info if needed.如果需要,我可以提供更多配置和信息。

As listed in its reference documentation , Spring Boot 2.5.6 requires Hikari 4.0.3. 如其参考文档中所列,Spring Boot 2.5.6 需要 Hikari 4.0.3。 You should upgrade Hikari.你应该升级 Hikari。

It was a version issue of HikariCP.这是 HikariCP 的版本问题。 I noticed HikariDataSource came from com.zaxxer.HikariCP-java7.2.4.13, which was brought by a Quartz dependency.我注意到 HikariDataSource 来自 com.zaxxer.HikariCP-java7.2.4.13,它是由 Quartz 依赖项带来的。

I excluded this HikariCP library version from Quartz explicitly我明确地从 Quartz 中排除了这个 HikariCP 库版本

<dependency>
  <groupId>org.quartz-scheduler</groupId>
  <artifactId>quartz</artifactId>
  <version>${quartz.version}</version>
  <exclusions>
    <exclusion>
      <groupId>com.zaxxer</groupId>
      <artifactId>HikariCP-java7</artifactId>
    </exclusion>
  </exclusions>
</dependency>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用com.zaxxer.hikari.HikariDataSource时出错 - Error using com.zaxxer.hikari.HikariDataSource 无法将 &#39;&#39; 下的属性绑定到 com.zaxxer.hikari.HikariDataSource - Failed to bind properties under '' to com.zaxxer.hikari.HikariDataSource 无法将“下的属性绑定到 com.zaxxer.hikari.HikariDataSource:” Springboot - Failed to bind properties under " to com.zaxxer.hikari.HikariDataSource:" Springboot 无法将“”下的属性绑定到com.zaxxer.hikari.HikariDataSource: - Failed to bind properties under '' to com.zaxxer.hikari.HikariDataSource: 无法将“”下的属性绑定到 com.zaxxer.hikari.HikariDataSource: spring boot 2.4.1 - Failed to bind properties under '' to com.zaxxer.hikari.HikariDataSource: spring boot 2.4.1 如何修复“无法将''下的属性绑定到 com.zaxxer.hikari.HikariDataSource”错误? - How do i fix the “Failed to bind properties under '' to com.zaxxer.hikari.HikariDataSource” error? Spring 启动 JPA 与骆驼 JPA 引发无法实例化 [com.zaxxer.hikari.HikariDataSource] - Spring Boot JPA with Camel JPA throws Failed to instantiate [com.zaxxer.hikari.HikariDataSource] javax.management.InstanceAlreadyExistsException: com.zaxxer.hikari:name=dataSource,type=HikariDataSource - javax.management.InstanceAlreadyExistsException: com.zaxxer.hikari:name=dataSource,type=HikariDataSource 找不到记录器的附加程序(com.zaxxer.hikari.HikariConfig) - No appenders could be found for logger (com.zaxxer.hikari.HikariConfig) com.zaxxer.hikari.pool.PoolInitializationException:池初始化期间的异常 - com.zaxxer.hikari.pool.PoolInitializationException: Exception during pool initialization
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM