首页 > 解决方案 > Spring Boot Starter Data JPA - liquibase 错误

问题描述

我正在尝试使用 Spring Boot 中的 JPA 启动器创建一个 postgres 数据库。我有一个简单的实体。

@Entity
@Table(name = "project")
data class Project(
    val name: String,
    val url: String,
    val owner: String,
    val language: Language,

    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    val id: Long? = null,
    val description: String? = null,

    @ElementCollection
    val tags: List<String> = listOf(),
    val license: String? = null
)

enum class Language {
    KOTLIN, JAVASCRIPT, JAVA
}

我的 application.properties 中有这个

logging.level.com.project=DEBUG
spring.datasource.url=jdbc:postgresql://localhost:5432/db
spring.datasource.username=user
spring.datasource.password=password
spring.jpa.generate-ddl=true

我的模块的gradle文件:

apply plugin: 'kotlin-spring'
apply plugin: "kotlin-jpa"
apply plugin: 'kotlin'

dependencies {
    compile("org.springframework.boot:spring-boot-starter:$spring_boot_version")
    compile("org.springframework.boot:spring-boot-starter-data-jpa:$spring_boot_version")
    compile("org.postgresql:postgresql:$postgres_version")
}

当 Igo 运行服务器时,我得到:

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.boot.autoconfigure.liquibase.LiquibaseAutoConfiguration$LiquibaseConfiguration':

但我不使用 liquibase?预期的行为应该是spring在postgresql中生成我的表

标签: spring-bootkotlinspring-data-jpa

解决方案


通过添加修复

spring.liquibase.enabled=false

到配置


推荐阅读