【发布时间】: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&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
ERROR message from hibernate configuration when viewing the database
【问题讨论】: