运行 eclipse 中来自 springboot 的 liquibase

run liquibase from springboot inside eclipse

我 运行 一个 spring eclipse 中的启动应用程序:

@SpringBootApplication
public class StatBasketServerApplication {

    public static void main(String[] args) {
        SpringApplication.run(StatBasketServerApplication.class, args);
    }
}

属性文件:

spring.jpa.hibernate.ddl-auto=none

 spring.h2.console.enabled=true

spring.datasource.url= jdbc:postgresql://localhost:5432/
spring.datasource.username=postgres
spring.datasource.password=postgres

spring.jpa.hibernate.ddl-auto=create-drop

当应用程序启动时,没有完成 liquibase 更改。

我需要在 gradle 构建中做些什么吗?如果我查看控制台,我看不到任何关于 liquibase 的信息。

变更日志在里面

resouces/db/changelog.xml

更新

这是我的构建文件

buildscript {
    ext {
        springBootVersion = '1.4.1.RELEASE'
    }
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
    }
}

apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'spring-boot'

jar {
    baseName = 'statBasketServer'
    version = '0.0.1-SNAPSHOT'
}
sourceCompatibility = 1.8
targetCompatibility = 1.8

repositories {
    mavenCentral()
} 


dependencies {
    compile('org.springframework.boot:spring-boot-starter')
    compile("org.springframework.boot:spring-boot-starter-web")
    compile("org.springframework.boot:spring-boot-starter-data-jpa")    
    compile("org.springframework.boot:spring-boot-starter-data-solr")
    compile("org.springframework.boot:spring-boot-starter-hateoas")
    compile("org.json:json:20141113")
    compile("org.postgresql:postgresql:9.4-1201-jdbc4")
    compile("com.fasterxml.jackson.dataformat:jackson-dataformat-xml:2.6.1")
    compile("org.codehaus.woodstox:woodstox-core-asl:4.4.1")
    compile group: 'org.postgresql', name: 'postgresql', version: '9.4.1211.jre7'        
    testCompile("org.springframework.boot:spring-boot-starter-test") 
    testCompile("com.jayway.jsonpath:json-path-assert:0.8.1") 

}
  1. 您需要将 org.liquibase:liquibase-core 添加到您的类路径
  2. 默认情况下它会读取db/changelog/db.changelog-master.yaml作为默认的更新日志,或者你可以通过liquibase.change-logapplication.properties中配置它,spring引导也支持xml、json liquibase 脚本。

Here是springboot提供的一个例子,大家可以参考一下,有一点是这个例子是使用maven作为构建工具