首页 > 解决方案 > com.zaxxer.hikari.pool.HikariPool$PoolInitializationException:池初始化期间出现异常:springHikariCP - 连接不可用

问题描述

你能帮忙吗:

我启动了我的应用程序,但它在几秒钟后关闭,出现以下错误:

2018-09-21 17:34:59,500  INFO | main | com.zaxxer.hikari.HikariDataSource                        93 | springHikariCP - is starting. | 
        2018-09-21 17:35:29,535  INFO | main | com.zaxxer.hikari.pool.HikariPool                        213 | springHikariCP - is closing down. | 
        2018-09-21 17:35:29,855  WARN | main | o.s.context.support.ClassPathXmlApplicationContext       551 | Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'appEntityManagerFactory' defined in class path resource [META-INF/spring/app.repositories.xml]: Invocation of init method failed; nested exception is com.zaxxer.hikari.pool.HikariPool$PoolInitializationException: Exception during pool initialization: springHikariCP - Connection is not available, request timed out after 30002ms. | 
        2018-09-21 17:35:29,870 ERROR | main | com.my.jos.jmx.Driver                            72 | CRITICAL ERROR: Error encountered starting application. | 
        org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'appEntityManagerFactory' defined in class path resource [META-INF/spring/app.repositories.xml]: Invocation of init method failed; nested exception is com.zaxxer.hikari.pool.HikariPool$PoolInitializationException: Exception during pool initialization: springHikariCP - Connection is not available, request timed out after 30002ms.

标签: spring-boothikaricpspring-framework-beans

解决方案


如果您不需要使用 HikariCP,您可以检查您的 POM,如果它已经定义,请考虑将其删除。

您还可以确保使用以下依赖项:

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>

假设您使用的是 xml 配置,您可以确保正确设置数据源:

如何在 Spring 中通过 XML 定义 MySql 数据源 bean


推荐阅读