Merge branch '2.1.x'
Closes gh-18103
This commit is contained in:
@@ -301,7 +301,7 @@ public class FlywayAutoConfiguration {
|
||||
|
||||
/**
|
||||
* Additional configuration to ensure that {@link EntityManagerFactory} beans depend
|
||||
* on the {@code flyway} bean.
|
||||
* on any {@link Flyway} beans.
|
||||
*/
|
||||
@Configuration(proxyBeanMethods = false)
|
||||
@ConditionalOnClass(LocalContainerEntityManagerFactoryBean.class)
|
||||
@@ -309,14 +309,14 @@ public class FlywayAutoConfiguration {
|
||||
protected static class FlywayJpaDependencyConfiguration extends EntityManagerFactoryDependsOnPostProcessor {
|
||||
|
||||
public FlywayJpaDependencyConfiguration() {
|
||||
super("flyway");
|
||||
super(Flyway.class);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Additional configuration to ensure that {@link JdbcOperations} beans depend on the
|
||||
* {@code flyway} bean.
|
||||
* Additional configuration to ensure that {@link JdbcOperations} beans depend on any
|
||||
* {@link Flyway} beans.
|
||||
*/
|
||||
@Configuration(proxyBeanMethods = false)
|
||||
@ConditionalOnClass(JdbcOperations.class)
|
||||
@@ -324,14 +324,14 @@ public class FlywayAutoConfiguration {
|
||||
protected static class FlywayJdbcOperationsDependencyConfiguration extends JdbcOperationsDependsOnPostProcessor {
|
||||
|
||||
public FlywayJdbcOperationsDependencyConfiguration() {
|
||||
super("flyway");
|
||||
super(Flyway.class);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Additional configuration to ensure that {@link NamedParameterJdbcOperations} beans
|
||||
* depend on the {@code flyway} bean.
|
||||
* depend on any {@link Flyway} beans.
|
||||
*/
|
||||
@Configuration(proxyBeanMethods = false)
|
||||
@ConditionalOnClass(NamedParameterJdbcOperations.class)
|
||||
@@ -340,7 +340,7 @@ public class FlywayAutoConfiguration {
|
||||
extends NamedParameterJdbcOperationsDependsOnPostProcessor {
|
||||
|
||||
public FlywayNamedParameterJdbcOperationsDependencyConfiguration() {
|
||||
super("flyway");
|
||||
super(Flyway.class);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -49,6 +49,10 @@ import org.springframework.core.Ordered;
|
||||
import org.springframework.core.annotation.Order;
|
||||
import org.springframework.core.io.DefaultResourceLoader;
|
||||
import org.springframework.core.io.ResourceLoader;
|
||||
import org.springframework.jdbc.core.JdbcOperations;
|
||||
import org.springframework.jdbc.core.JdbcTemplate;
|
||||
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcOperations;
|
||||
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate;
|
||||
import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean;
|
||||
import org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter;
|
||||
import org.springframework.stereotype.Component;
|
||||
@@ -293,6 +297,13 @@ class FlywayAutoConfigurationTests {
|
||||
.run((context) -> assertThat(context).hasNotFailed());
|
||||
}
|
||||
|
||||
@Test
|
||||
void customFlywayWithJdbc() {
|
||||
this.contextRunner
|
||||
.withUserConfiguration(EmbeddedDataSourceConfiguration.class, CustomFlywayWithJdbcConfiguration.class)
|
||||
.run((context) -> assertThat(context).hasNotFailed());
|
||||
}
|
||||
|
||||
@Test
|
||||
void overrideBaselineVersionString() {
|
||||
this.contextRunner.withUserConfiguration(EmbeddedDataSourceConfiguration.class)
|
||||
@@ -530,7 +541,7 @@ class FlywayAutoConfigurationTests {
|
||||
}
|
||||
|
||||
@Bean
|
||||
Flyway flyway() {
|
||||
Flyway customFlyway() {
|
||||
return Flyway.configure().load();
|
||||
}
|
||||
|
||||
@@ -545,6 +556,32 @@ class FlywayAutoConfigurationTests {
|
||||
|
||||
}
|
||||
|
||||
@Configuration
|
||||
static class CustomFlywayWithJdbcConfiguration {
|
||||
|
||||
private final DataSource dataSource;
|
||||
|
||||
protected CustomFlywayWithJdbcConfiguration(DataSource dataSource) {
|
||||
this.dataSource = dataSource;
|
||||
}
|
||||
|
||||
@Bean
|
||||
Flyway customFlyway() {
|
||||
return Flyway.configure().load();
|
||||
}
|
||||
|
||||
@Bean
|
||||
JdbcOperations jdbcOperations() {
|
||||
return new JdbcTemplate(this.dataSource);
|
||||
}
|
||||
|
||||
@Bean
|
||||
NamedParameterJdbcOperations namedParameterJdbcOperations() {
|
||||
return new NamedParameterJdbcTemplate(this.dataSource);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Component
|
||||
static class MockFlywayMigrationStrategy implements FlywayMigrationStrategy {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user