gpt4 book ai didi

java - hibernate :无法从数据库获取建议的身份策略列表。可能是 JDBC 驱动程序问题

转载 作者:行者123 更新时间:2023-12-01 18:03:35 25 4
gpt4 key购买 nike

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

构建.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 的原因是 hibernate 配置没有检测到我项目的类路径。

我的 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

最佳答案

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

关于java - hibernate :无法从数据库获取建议的身份策略列表。可能是 JDBC 驱动程序问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60593407/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com