我在Spring Boot 2.1.2
和Hibernate 5.4.1
中有一个项目。我选择HikariCP 3.3.1
作为与MySQL Connector 8.0.15
一切似乎都正常,但是一段时间后某些例外开始出现在日志中:
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'
}
答案 0 :(得分:0)
您的异常消息是:java.lang.NoClassDefFoundError:com / mysql / cj / log / ProfilerEventHandlerFactory
您的mysql驱动程序似乎有问题。
您可以显示pom.xml吗? 可能有助于解决问题。