mirror of
https://github.com/spring-projects/spring-boot.git
synced 2024-07-15 01:07:30 +08:00
Allow indexed access of flyway.locations
This commit allows to use the `flyway.locations` in an indexed fashion (i.e. typically in YAML configuration). See gh-4973
This commit is contained in:
parent
5ef6903690
commit
a749855cb5
@ -114,6 +114,8 @@ public class FlywayAutoConfiguration {
|
||||
else {
|
||||
flyway.setDataSource(this.dataSource);
|
||||
}
|
||||
//Explicitly set locations because the getter doesn't return a mutable value
|
||||
flyway.setLocations(this.properties.getLocations().toArray(new String[0]));
|
||||
return flyway;
|
||||
}
|
||||
|
||||
|
@ -16,6 +16,7 @@
|
||||
|
||||
package org.springframework.boot.autoconfigure.flyway;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
@ -39,7 +40,7 @@ public class FlywayProperties {
|
||||
/**
|
||||
* Locations of migrations scripts.
|
||||
*/
|
||||
private List<String> locations = Arrays.asList("db/migration");
|
||||
private List<String> locations = new ArrayList<String>(Arrays.asList("db/migration"));
|
||||
|
||||
/**
|
||||
* Check that migration scripts location exists.
|
||||
|
@ -104,8 +104,8 @@ public class FlywayAutoConfigurationTests {
|
||||
|
||||
@Test
|
||||
public void overrideLocations() throws Exception {
|
||||
EnvironmentTestUtils.addEnvironment(this.context,
|
||||
"flyway.locations:classpath:db/changelog,classpath:db/migration");
|
||||
EnvironmentTestUtils.addEnvironment(this.context, "flyway.locations[0]:classpath:db/changelog",
|
||||
"flyway.locations[1]:classpath:db/migration");
|
||||
registerAndRefresh(EmbeddedDataSourceConfiguration.class,
|
||||
FlywayAutoConfiguration.class,
|
||||
PropertyPlaceholderAutoConfiguration.class);
|
||||
|
Loading…
Reference in New Issue
Block a user