@ -36,11 +36,13 @@ import org.flywaydb.core.api.configuration.FluentConfiguration;
import org.springframework.beans.factory.ObjectProvider ;
import org.springframework.boot.autoconfigure.AutoConfigureAfter ;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration ;
import org.springframework.boot.autoconfigure.condition.AnyNestedCondition ;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean ;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass ;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean ;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty ;
import org.springframework.boot.autoconfigure.data.jpa.EntityManagerFactoryDependsOnPostProcessor ;
import org.springframework.boot.autoconfigure.flyway.FlywayAutoConfiguration.FlywayDataSourceCondition ;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration ;
import org.springframework.boot.autoconfigure.jdbc.DataSourceProperties ;
import org.springframework.boot.autoconfigure.jdbc.JdbcOperationsDependsOnPostProcessor ;
@ -52,6 +54,7 @@ import org.springframework.boot.context.properties.EnableConfigurationProperties
import org.springframework.boot.context.properties.PropertyMapper ;
import org.springframework.boot.jdbc.DatabaseDriver ;
import org.springframework.context.annotation.Bean ;
import org.springframework.context.annotation.Conditional ;
import org.springframework.context.annotation.Configuration ;
import org.springframework.core.convert.TypeDescriptor ;
import org.springframework.core.convert.converter.GenericConverter ;
@ -82,7 +85,7 @@ import org.springframework.util.StringUtils;
@SuppressWarnings ( "deprecation" )
@Configuration ( proxyBeanMethods = false )
@ConditionalOnClass ( Flyway . class )
@Conditional OnBean ( DataSource. class )
@Conditional ( Flyway DataSourceCondition . class )
@ConditionalOnProperty ( prefix = "spring.flyway" , name = "enabled" , matchIfMissing = true )
@AutoConfigureAfter ( { DataSourceAutoConfiguration . class ,
JdbcTemplateAutoConfiguration . class , HibernateJpaAutoConfiguration . class } )
@ -462,4 +465,23 @@ public class FlywayAutoConfiguration {
}
static final class FlywayDataSourceCondition extends AnyNestedCondition {
FlywayDataSourceCondition ( ) {
super ( ConfigurationPhase . REGISTER_BEAN ) ;
}
@ConditionalOnBean ( DataSource . class )
private static final class DataSourceBeanCondition {
}
@ConditionalOnProperty ( prefix = "spring.flyway" , name = "url" ,
matchIfMissing = false )
private static final class FlywayUrlCondition {
}
}
}