【问题标题】:Exception in thread "HikariPool-3 connection closer"线程“HikariPool-3 连接更紧密”中的异常
【发布时间】:2019-07-16 00:44:20
【问题描述】:

我在Spring Boot 2.1.2Hibernate 5.4.1 有一个项目。我选择HikariCP 3.3.1 作为与MySQL Connector 8.0.15 连接的MySQL 数据库的池管理器

一切似乎都正常,但一些异常在一段时间后开始出现在日志中:

Exception in thread "HikariPool-4 connection closer" java.lang.NoClassDefFoundError: com/mysql/cj/log/ProfilerEventHandlerFactory
        at com.mysql.cj.jdbc.ConnectionImpl.realClose(ConnectionImpl.java:1765)
        at com.mysql.cj.jdbc.ConnectionImpl.close(ConnectionImpl.java:720)
        at com.zaxxer.hikari.pool.PoolBase.quietlyCloseConnection(PoolBase.java:138)
        at com.zaxxer.hikari.pool.HikariPool.lambda$closeConnection$1(HikariPool.java:447)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
        at java.lang.Thread.run(Thread.java:748)

我不知道这意味着什么,因此如何摆脱这些消息。是否与我的控制器在一段时间后无法连接到数据库有关?

这是我的 hibernate.cfg.xml 的一部分:

    <!--HikariCP settings-->
    <!--Maximum waiting time for a connection from the pool-->
    <property name="hibernate.connection.provider_class">org.hibernate.hikaricp.internal.HikariCPConnectionProvider</property>
    <property name="hibernate.hikari.connectionTimeout">20000</property>
    <!--Minimum number of ideal connections in the pool-->
    <property name="hibernate.hikari.minimumIdle">10</property>
    <!--Maximum number of actual connection in the pool-->
    <property name="hibernate.hikari.maximumPoolSize">100</property>
    <!--Maximum time that a connection is allowed to sit ideal in the pool-->
    <property name="hibernate.hikari.idleTimeout">300000</property>
    <!--Cache-->
    <property name="hibernate.hikari.dataSource.cachePrepStmts">true</property>
    <property name="hibernate.hikari.dataSource.prepStmtCacheSize">500</property>
    <property name="hibernate.hikari.dataSource.prepStmtCacheSqlLimit">2048</property>
    <property name="hibernate.hikari.dataSource.useServerPrepStmts">true</property>


    <property name="hibernate.connection.autocommit">false</property>
    <property name="hibernate.dialect">org.hibernate.dialect.MySQL57Dialect</property>
    <property name="hibernate.connection.useUnicode">true</property>
    <property name="hibernate.connection.CharSet">utf8mb4</property>
    <property name="hibernate.connection.characterEncoding">utf8</property>
    <property name="hibernate.dialect.storage_engine">innodb</property>
    <property name="hibernate.id.new_generator_mappings">true</property>
    <property name="hibernate.show_sql">false</property>
    <property name="hibernate.format_sql">false</property>
    <property name="use_sql_comments">false</property>
    <property name="hibernate.current_session_context_class">thread</property>
    <property name="hibernate.cache.provider_class">org.hibernate.cache.internal.NoCachingRegionFactory</property>
    <property name="jadira.usertype.autoRegisterUserTypes">true</property>

我使用 gradle,这是我的 maven 依赖项:

dependencies {
    // This dependency is exported to consumers, that is to say found on their compile classpath.
    api 'org.apache.commons:commons-math3:3.6.1'

    implementation 'com.google.guava:guava:27.0.1-jre'

    implementation 'org.springframework.boot:spring-boot-starter-web:2.1.2.RELEASE'
    implementation 'org.springframework.boot:spring-boot-starter-actuator:2.1.2.RELEASE'
    implementation 'org.springframework.boot:spring-boot-starter-mail:2.1.2.RELEASE'
    implementation 'io.springfox:springfox-swagger2:2.9.2'
    implementation 'io.springfox:springfox-swagger-ui:2.9.2'
    implementation 'org.hibernate:hibernate-core:5.4.1.Final'
    implementation 'org.hibernate:hibernate-jpamodelgen:5.4.1.Final'
    implementation 'com.zaxxer:HikariCP:3.3.1'
    implementation 'mysql:mysql-connector-java:8.0.15'
    implementation 'com.fasterxml.jackson.jaxrs:jackson-jaxrs-json-provider:2.9.8'
    implementation 'com.fasterxml.jackson.datatype:jackson-datatype-joda:2.9.8'
    implementation 'org.jadira.usertype:usertype.core:7.0.0.CR1'
    implementation 'joda-time:joda-time:2.10.1'
    implementation 'com.google.firebase:firebase-admin:6.7.0'
    implementation 'org.apache.tika:tika-parsers:1.20'

    implementation 'com.wildbit.java:postmark:1.2.0'
}

【问题讨论】:

    标签: hibernate spring-boot mysql-connector hikaricp


    【解决方案1】:

    您的异常消息是:java.lang.NoClassDefFoundError: com/mysql/cj/log/ProfilerEventHandlerFactory

    您的 mysql 驱动程序似乎有问题。

    你能显示你的 pom.xml 吗? 这可能有助于解决问题。

    【讨论】:

    • Maven 依赖项看起来不错,mysql-connector-java-8.0.15.jar 是否没有下载到您的 Maven 存储库?尝试在 $HOME/.m2/repository 中找到它,
    猜你喜欢
    • 2016-02-15
    • 2012-08-13
    • 2012-01-18
    • 1970-01-01
    • 2016-01-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-03-14
    相关资源
    最近更新 更多