【问题标题】:HIBERNATE: Could not get list of suggested identity strategies from database. Probably a JDBC driver problem休眠:无法从数据库中获取建议的身份策略列表。可能是 JDBC 驱动程序问题
【发布时间】:2020-03-09 00:38:17
【问题描述】:

我正在尝试使用休眠逆向工程从我的 mysql 数据库中自动生成我的实体模型。我正在使用 mysql server 8 并开发一个 spring boot 应用程序 2.2.4。在我的应用程序中,我已经在 build.gradle 中包含了 spring-jpa 和 mysql 连接驱动程序。

build.gradle

buildscript {
  ext {
    springBootVersion = '2.2.4.RELEASE'
  }
  repositories {
    mavenCentral()
    jcenter()
  }
  dependencies {
    classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
  }
}

apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'org.springframework.boot'
apply plugin: 'io.spring.dependency-management'

sourceCompatibility = 1.8
targetCompatibility = 1.8

repositories {
 mavenCentral()
 jcenter()
}

dependencies {
 implementation 'org.springframework.boot:spring-boot-starter-web'
 implementation 'org.springframework.kafka:spring-kafka'
 implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
 implementation 'mysql:mysql-connector-java:8.0.19'
}

hibernate.cfg.xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC
    "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
    "http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
    <property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
    <property name="hibernate.connection.password">root</property>
    <property name="hibernate.connection.url">jdbc:mysql://localhost:3306/test?useTimezone=true&amp;serverTimezone=UTC</property>
    <property name="hibernate.connection.username">root</property>
    <property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>
    <property name="hibernate.default_schema">test</property>
</session-factory>
</hibernate-configuration>

我将我的 java 库和 java 编译器降级到 1.8,但我最初使用的是 java 11。我降级到 java 1.8 的原因是休眠配置未检测到我的项目的类路径。

我的 mysql java 连接器:mysql-connector-java-8.0.19

hibernate config part 1

hibernate config part 2

ERROR message from hibernate configuration when viewing the database

【问题讨论】:

    标签: java hibernate


    【解决方案1】:

    我将我的 mysql 版本降级到 5.x,它现在可以工作了。我不知道为什么它不适用于我的版本 8

    【讨论】:

      猜你喜欢
      • 2018-02-17
      • 2016-02-15
      • 2016-11-19
      • 1970-01-01
      • 2017-05-29
      • 1970-01-01
      • 2018-07-03
      • 2011-07-25
      • 1970-01-01
      相关资源
      最近更新 更多