我有一个基于SpringBoot 3的Gradle项目,使用Hibernate 6和Liquibase。
目标是使用liquibase-hibernate6
依赖项生成一个初始Liquibase变更日志,其中包含我的Java Entity类(即Item.java
)的详细信息。
问题是生成的更新日志基本上是空的。
为了从Java Entity类生成Liquibase变更日志,缺少了什么?
val liquibaseVersion: String = "4.23.0"
val liquibaseGradlePluginVersion: String = "2.2.0"
plugins {
java
war
id("org.springframework.boot") version "3.1.1"
id("io.spring.dependency-management") version "1.1.0"
id("org.liquibase.gradle") version "2.2.0"
}
group = "com.example"
version = "0.0.1-SNAPSHOT"
java {
sourceCompatibility = JavaVersion.VERSION_17
}
repositories {
mavenCentral()
}
dependencies {
implementation("org.postgresql:postgresql:42.6.0")
implementation("info.picocli:picocli:4.6.3")
implementation("org.springframework.boot:spring-boot-starter-data-jpa")
implementation("org.springframework.boot:spring-boot-starter-web")
implementation("org.liquibase:liquibase-core:$liquibaseVersion")
implementation("org.liquibase:liquibase-gradle-plugin:$liquibaseGradlePluginVersion")
implementation("org.hibernate.orm:hibernate-core:6.2.5.Final")
implementation("org.liquibase.ext:liquibase-hibernate6:$liquibaseVersion")
implementation("com.fasterxml.jackson.core:jackson-core")
implementation("com.fasterxml.jackson.core:jackson-databind")
implementation("com.fasterxml.jackson.dataformat:jackson-dataformat-yaml")
providedRuntime("org.springframework.boot:spring-boot-starter-tomcat")
liquibaseRuntime("org.postgresql:postgresql:42.6.0")
liquibaseRuntime("info.picocli:picocli:4.6.3")
liquibaseRuntime("org.liquibase:liquibase-core:$liquibaseVersion")
liquibaseRuntime("org.liquibase.ext:liquibase-hibernate6:$liquibaseVersion")
liquibaseRuntime("org.hibernate.orm:hibernate-core:6.2.5.Final")
liquibaseRuntime("org.springframework.boot:spring-boot-starter-data-jpa")
liquibaseRuntime(sourceSets.getByName("main").output)
}
tasks.withType<Test> {
useJUnitPlatform()
}
liquibase {
activities.register("main") {
this.arguments = mapOf(
"changelogFile" to "src/main/resources/config/liquibase/changelog/0.1.0/000000_00000000_initial-changelog.xml",
"url" to "hibernate:spring:com.example?dialect=org.hibernate.dialect.PostgreSQLDialect"
)
}
}
字符集
我有一个Java实体:
package com.example.demo;
import jakarta.persistence.*;
@Entity
public class Item {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@Column(name = "id", nullable = false)
private Long id;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
}
型
通过Gradle运行generateChangeLog
后Liquibase更新日志的内容:
<?xml version="1.1" encoding="UTF-8" standalone="no"?>
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog" xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog-ext http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-ext.xsd http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-latest.xsd"/>
型
1条答案
按热度按时间i34xakig1#
老实说,我想知道为什么这是甚至工作.因为你使用Postgres你必须提供至少一个用户名.不安静的确定密码.你可以有一个用户在Postgres没有密码?无论如何,更重要的是,你必须指向你的包与你的实体类,如解释这里.
使用Gradle文件的此更新版本重试:
字符集