diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/liquibase/LiquibaseAutoConfiguration.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/liquibase/LiquibaseAutoConfiguration.java index 62ad24bd91..8f525258e1 100644 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/liquibase/LiquibaseAutoConfiguration.java +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/liquibase/LiquibaseAutoConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2016 the original author or authors. + * Copyright 2012-2017 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -76,11 +76,12 @@ public class LiquibaseAutoConfiguration { private final DataSource liquibaseDataSource; public LiquibaseConfiguration(LiquibaseProperties properties, - ResourceLoader resourceLoader, DataSource dataSource, + ResourceLoader resourceLoader, + ObjectProvider dataSourceProvider, @LiquibaseDataSource ObjectProvider liquibaseDataSourceProvider) { this.properties = properties; this.resourceLoader = resourceLoader; - this.dataSource = dataSource; + this.dataSource = dataSourceProvider.getIfUnique(); this.liquibaseDataSource = liquibaseDataSourceProvider.getIfAvailable(); } diff --git a/spring-boot-docs/src/main/asciidoc/howto.adoc b/spring-boot-docs/src/main/asciidoc/howto.adoc index 87e523c575..7e715d125e 100644 --- a/spring-boot-docs/src/main/asciidoc/howto.adoc +++ b/spring-boot-docs/src/main/asciidoc/howto.adoc @@ -2210,6 +2210,12 @@ The master change log is by default read from `db/changelog/db.changelog-master. can be set using `liquibase.change-log`. In addition to YAML, Liquibase also supports JSON, XML, and SQL change log formats. +By default Liquibase will autowire the (`@Primary`) `DataSource` in your context and use +that for migrations. If you like to use a different `DataSource` you can create one and +mark its `@Bean` as `@LiquibaseDataSource` - if you do that remember to create another one +and mark it as `@Primary` if you want two data sources. Or you can use Liquibase's native +`DataSource` by setting `liquibase.[url,user,password]` in external properties. + See {sc-spring-boot-autoconfigure}/liquibase/LiquibaseProperties.{sc-ext}[`LiquibaseProperties`] for details of available settings like contexts, default schema etc.