Commit e6c18a00 authored by Phillip Webb's avatar Phillip Webb

Polish

parent 77bf5583
......@@ -97,8 +97,8 @@ public class DataSourceAutoConfiguration {
@Autowired
private DataSourceProperties properties;
@ConfigurationProperties(prefix = DataSourceProperties.PREFIX)
@Bean
@ConfigurationProperties(prefix = DataSourceProperties.PREFIX)
public DataSource dataSource() {
DataSourceBuilder factory = DataSourceBuilder
.create(this.properties.getClassLoader())
......@@ -205,8 +205,7 @@ public class DataSourceAutoConfiguration {
return ConditionOutcome.match("existing auto database detected");
}
if (BeanFactoryUtils.beanNamesForTypeIncludingAncestors(
context.getBeanFactory(), DataSource.class, true, false).length > 0) {
if (hasBean(context, DataSource.class)) {
return ConditionOutcome
.match("Existing bean configured database detected");
}
......@@ -214,6 +213,10 @@ public class DataSourceAutoConfiguration {
return ConditionOutcome.noMatch("no existing bean configured database");
}
private boolean hasBean(ConditionContext context, Class<?> type) {
return BeanFactoryUtils.beanNamesForTypeIncludingAncestors(
context.getBeanFactory(), type, true, false).length > 0;
}
}
}
......@@ -25,7 +25,7 @@ import org.springframework.util.ClassUtils;
import org.springframework.util.StringUtils;
/**
* Base class for configuration of a database pool.
* Base class for configuration of a data source.
*
* @author Dave Syer
* @author Maciej Walkowiak
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment