我已经按如下所示设置了Spring应用程序,但它总是给我一个错误
org.springframework.beans.factory.BeanCreationException:
Error creating bean with name 'entityManagerFactory'
defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaConfiguration.class]: Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: org/hibernate/query/BindableType
字符串
这是一个基本的spring设置,没有任何类,只是配置
plugins {
java
id("org.springframework.boot") version "2.7.15"
id("io.spring.dependency-management") version "1.0.15.RELEASE"
}
group = "com.example"
version = "0.0.1-SNAPSHOT"
java {
sourceCompatibility = JavaVersion.VERSION_17
}
repositories {
mavenCentral()
}
dependencies {
implementation("org.springframework.boot:spring-boot-starter-actuator")
implementation("org.springframework.boot:spring-boot-starter-data-jpa")
implementation("org.springframework.boot:spring-boot-starter-security")
implementation("org.springframework.boot:spring-boot-starter-validation")
implementation("org.springframework.boot:spring-boot-starter-web")
testImplementation("org.springframework.boot:spring-boot-starter-test")
testImplementation("org.springframework.security:spring-security-test")
//DB
implementation("org.postgresql:postgresql")
implementation("org.liquibase:liquibase-core:4.23.1")
implementation("com.vladmihalcea:hibernate-types-60:2.21.1")
}
tasks.withType<Test> {
useJUnitPlatform()
}
型
application.properties
spring.main.banner-mode=off
server.port=8090
# For liquibase use
spring.datasource.url=jdbc:postgresql://test.com:5432/main
spring.jpa.hibernate.ddl-auto=
spring.liquibase.enabled=false
spring.liquibase.liquibase-schema=test
# PostgreSQL
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.PostgreSQLDialect
spring.datasource.username=admin
spring.datasource.password=xxx
spring.jpa.properties.hibernate.default_schema=test
型
1条答案
按热度按时间lx0bsm1f1#
Sping Boot 2.7.15使用Hibernate 5.6.15.Final,因此您需要包含com.vladmihalcea:hibernate-types-55而不是com.vladmihalcea:hibernate-types-60。hibernate-types-60仅与Hibernate 6一起使用。BindableType是Hibernate 6类,在Hibernate 5中不存在。我猜hibernate-type-60使用BindableType类。
您可能希望迁移到hypersistence-utils-hibernate-55。有关您可能希望升级的原因的信息,请参阅this。