liquibase / liquibase-groovy-dsl

The official Groovy DSL for Liquibase
Other
83 stars 34 forks source link

Please provide example documentation to integrate in Spring Boot Liquibase #48

Closed devpro1981 closed 4 years ago

devpro1981 commented 4 years ago

Trying to integrate like this: build.gradle dependencies { implementation 'org.liquibase:liquibase-core' implementation 'org.liquibase:liquibase-groovy-dsl:2.1.1' runtimeOnly 'com.h2database:h2' runtime 'org.liquibase:liquibase-core' runtime 'org.liquibase:liquibase-groovy-dsl:2.1.1' }

In Spring Boot application.properties spring.liquibase.change-log=classpath:db/changelog/changeset0002.groovy

This groovy file has the changelog DSL. But doing gradle bootRun throws following error:

Error creating bean with name 'liquibase' defined in class path resource [org/springframework/boot/autoconfigure/liquibase/LiquibaseAutoConfiguration$LiquibaseConfiguration.class]: Invocation of init method failed; nested exception is java.lang.ArrayIndexOutOfBoundsException: Index 1 out of bounds for length 1

bradwoo8621 commented 4 years ago
spring:
  datasource:
    driver-class-name: com.mysql.jdbc.Driver
    url: jdbc:mysql://127.0.0.1/your-schema?characterEncoding=UTF-8
    username: your-username
    password: your-pwd
  liquibase:
    change-log: META-INF/scripts/liquibase-index.groovy

but i've got another exception, IllegalAccessError thrown on visit private method is liquibase-groovy-dsl, which is exactly correct in unit test (junit5). still work on it.

devpro1981 commented 4 years ago

It works. I am using application.properties instead application.yml file. However, with the following setting, I got it working: spring.liquibase.change-log=classpath:META-INF/scripts/changeset0001.groovy,

where the directories META-INF/scripts exist under src/main/resources of my Gradle project structure and changeset0001.groovy is a usual Groovy DSL file.