Reputation: 5690
I try to generate database migrations from spring boot entity with mvn liquibase:diff but changeSets count: 0
here is my pom file
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>ch.Liquibase</groupId>
<artifactId>Liquibase</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>Liquibase</name>
<description>Liquibase</description>
<properties>
<java.version>21</java.version>
<spring-cloud.version>2023.0.0</spring-cloud.version>
</properties>
<dependencies>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.30</version>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
<version>3.2.0</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<version>3.2.4</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>8.0.30</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.liquibase</groupId>
<artifactId>liquibase-core</artifactId>
<version>4.24.0</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.11.0</version>
<configuration>
<source>8</source>
<target>8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.liquibase</groupId>
<artifactId>liquibase-maven-plugin</artifactId>
<version>4.24.0</version>
<configuration>
<propertyFile>src/main/resources/liquibase/config/liquibase-development.properties</propertyFile>
<promptOnNonLocalDatabase>true</promptOnNonLocalDatabase>
</configuration>
</plugin>
</plugins>
</build>
</project>
here is my liquibase-development.properties
changeLogFile=src/main/resources/liquibase/liquibase-changeLog.xml
diffChangeLogFile=src/main/resources/liquibase/liquibase-diff-changeLog.xml
outputChangeLogFile=src/main/resources/liquibase/liquibase-new-changeLog.xml
url=jdbc:mysql://localhost:3306/liquibase_demo_db
defaultSchemaName=liquibase_demo_db
username=root
password=123456
driver=com.mysql.cj.jdbc.Driver
referenceDefaultSchemaName=liquibase_demo_ref
referenceDriver=com.mysql.cj.jdbc.Driver
referenceUrl=jdbc:mysql://localhost:3306/liquibase_demo_ref
referenceUsername=root
referencePassword=123456
liquibase.generateChangesetCreatedValues=true
liquibase.pro.sql.inline=true
liquibase.includeCatalogInSpecification=true
liquibase.command.diffChangeLog.format=xml
liquibase.command.diffChangeLog.skipDatabaseStep=true
here is my application.properties
## Database Properties
# Spring DATASOURCE (DataSourceAutoConfiguration & DataSourceProperties)
spring.datasource.url = jdbc:mysql://localhost:3306/liquibase_demo_db?useSSL=false
spring.datasource.username = root
spring.datasource.password = 123456
# Hibernate Properties
spring.jpa.database-platform = org.hibernate.dialect.MySQL8Dialect
# LIQUIBASE (LiquibaseProperties)
spring.liquibase.change-log=classpath:liquibase/liquibase-changeLog.xml
spring.datasource.initialization-mode=always
spring.liquibase.default-schema=my_schema
spring.jpa.properties.hibernate.default_schema=my_schema
spring.liquibase.enabled=true
here is my entity model
package com.example.demo.model;
import com.example.demo.model.ModelEntity;
import jakarta.persistence.*;
import lombok.Getter;
import lombok.Setter;
import java.util.Date;
@Getter
@Setter
@Entity(name = "customers")
public class Customer {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@Column(name = "id", nullable = false)
private Long id;
private String name;
private String surname;
private String address;
}
here is my application file
package com.example.demo;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.ComponentScan;
@SpringBootApplication
@ComponentScan
public class DemoApplication {
public static void main(String[] args) {
SpringApplication.run(DemoApplication.class, args);
}
}
when i run mvn liquibase:diff
<?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:pro="http://www.liquibase.org/xml/ns/pro" 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/pro http://www.liquibase.org/xml/ns/pro/liquibase-pro-latest.xsd http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-latest.xsd"/>
got this message
changeSets count: 0
[INFO] No changesets to add.
i have tried various way but not changeset generated
hope someone will help me for this issue
Thanks in advance
Upvotes: 1
Views: 127