Skip to content

Commit 008aef6

Browse files
committed
Document @LiquibaseDataSource feature
Closes gh-8214
1 parent 21e8665 commit 008aef6

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/liquibase/LiquibaseAutoConfiguration.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2016 the original author or authors.
2+
* Copyright 2012-2017 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -76,11 +76,12 @@ public static class LiquibaseConfiguration {
7676
private final DataSource liquibaseDataSource;
7777

7878
public LiquibaseConfiguration(LiquibaseProperties properties,
79-
ResourceLoader resourceLoader, DataSource dataSource,
79+
ResourceLoader resourceLoader,
80+
ObjectProvider<DataSource> dataSourceProvider,
8081
@LiquibaseDataSource ObjectProvider<DataSource> liquibaseDataSourceProvider) {
8182
this.properties = properties;
8283
this.resourceLoader = resourceLoader;
83-
this.dataSource = dataSource;
84+
this.dataSource = dataSourceProvider.getIfUnique();
8485
this.liquibaseDataSource = liquibaseDataSourceProvider.getIfAvailable();
8586
}
8687

spring-boot-docs/src/main/asciidoc/howto.adoc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2210,6 +2210,12 @@ The master change log is by default read from `db/changelog/db.changelog-master.
22102210
can be set using `liquibase.change-log`. In addition to YAML, Liquibase also supports
22112211
JSON, XML, and SQL change log formats.
22122212

2213+
By default Liquibase will autowire the (`@Primary`) `DataSource` in your context and use
2214+
that for migrations. If you like to use a different `DataSource` you can create one and
2215+
mark its `@Bean` as `@LiquibaseDataSource` - if you do that remember to create another one
2216+
and mark it as `@Primary` if you want two data sources. Or you can use Liquibase's native
2217+
`DataSource` by setting `liquibase.[url,user,password]` in external properties.
2218+
22132219
See
22142220
{sc-spring-boot-autoconfigure}/liquibase/LiquibaseProperties.{sc-ext}[`LiquibaseProperties`]
22152221
for details of available settings like contexts, default schema etc.

0 commit comments

Comments
 (0)