springboot2+ integrate with liquibase

springboot already integrate with the liquibase, we just need some configuration
pom.xml

<parent>
		<groupId>org.springframework.bootgroupId>
		<artifactId>spring-boot-starter-parentartifactId>
		<version>2.0.5.RELEASEversion>
		<relativePath/> 
parent>
<dependencies>
		<dependency>
			<groupId>org.springframework.bootgroupId>
			<artifactId>spring-boot-starterartifactId>
		dependency>
		<dependency>
            <groupId>org.springframework.bootgroupId>
            <artifactId>spring-boot-starter-data-jpaartifactId>
        dependency>
		<dependency>
			<groupId>org.liquibasegroupId>
			<artifactId>liquibase-coreartifactId>
		dependency>
		<dependency>
            <groupId>mysqlgroupId>
            <artifactId>mysql-connector-javaartifactId>
        dependency>

		<dependency>
			<groupId>org.springframework.bootgroupId>
			<artifactId>spring-boot-starter-testartifactId>
			<scope>testscope>
		dependency>
	dependencies>

application.properties

#liquibase
spring.liquibase.enabled=true
spring.liquibase.change-log=classpath:/db/changelog/db.changelog-master.xml
#datasource
spring.datasource.driver-class-name=com.mysql.jdbc.Driver
spring.datasource.url=jdbc:mysql://localhost:3306/liquibase
spring.datasource.username=root
spring.datasource.password=root
#jpa
spring.jpa.database=MYSQL
spring.jpa.show-sql=true
spring.jpa.hibernate.ddl-auto=none

After above configuration, you can run the springboot application, the liquibase will be invoked.
Please refer to demo project: https://github.com/jasonsuzhou/LiquibaseDemo

你可能感兴趣的:(spring-boot)