@ -19,8 +19,10 @@ package org.springframework.boot.autoconfigure;
import java.io.IOException ;
import java.io.IOException ;
import java.util.ArrayList ;
import java.util.ArrayList ;
import java.util.Arrays ;
import java.util.Arrays ;
import java.util.Collections ;
import java.util.LinkedHashSet ;
import java.util.LinkedHashSet ;
import java.util.List ;
import java.util.List ;
import java.util.Map ;
import java.util.Set ;
import java.util.Set ;
import org.springframework.beans.BeansException ;
import org.springframework.beans.BeansException ;
@ -30,8 +32,6 @@ import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.BeanFactoryAware ;
import org.springframework.beans.factory.BeanFactoryAware ;
import org.springframework.beans.factory.NoSuchBeanDefinitionException ;
import org.springframework.beans.factory.NoSuchBeanDefinitionException ;
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory ;
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory ;
import org.springframework.boot.bind.PropertySourcesPropertyValues ;
import org.springframework.boot.bind.RelaxedDataBinder ;
import org.springframework.boot.bind.RelaxedPropertyResolver ;
import org.springframework.boot.bind.RelaxedPropertyResolver ;
import org.springframework.context.EnvironmentAware ;
import org.springframework.context.EnvironmentAware ;
import org.springframework.context.ResourceLoaderAware ;
import org.springframework.context.ResourceLoaderAware ;
@ -47,6 +47,7 @@ import org.springframework.core.type.classreading.CachingMetadataReaderFactory;
import org.springframework.core.type.classreading.MetadataReaderFactory ;
import org.springframework.core.type.classreading.MetadataReaderFactory ;
import org.springframework.util.Assert ;
import org.springframework.util.Assert ;
import org.springframework.util.ClassUtils ;
import org.springframework.util.ClassUtils ;
import org.springframework.util.StringUtils ;
/ * *
/ * *
* { @link DeferredImportSelector } to handle { @link EnableAutoConfiguration
* { @link DeferredImportSelector } to handle { @link EnableAutoConfiguration
@ -200,12 +201,22 @@ public class AutoConfigurationImportSelector
private List < String > getExcludeAutoConfigurationsProperty ( ) {
private List < String > getExcludeAutoConfigurationsProperty ( ) {
if ( getEnvironment ( ) instanceof ConfigurableEnvironment ) {
if ( getEnvironment ( ) instanceof ConfigurableEnvironment ) {
Excludes excludes = new Excludes ( ) ;
RelaxedPropertyResolver resolver = new RelaxedPropertyResolver (
RelaxedDataBinder binder = new RelaxedDataBinder ( excludes ,
this . environment , "spring.autoconfigure." ) ;
"spring.autoconfigure." ) ;
Map < String , Object > properties = resolver . getSubProperties ( "exclude" ) ;
binder . bind ( new PropertySourcesPropertyValues (
if ( properties . isEmpty ( ) ) {
( ( ConfigurableEnvironment ) getEnvironment ( ) ) . getPropertySources ( ) ) ) ;
return Collections . emptyList ( ) ;
return excludes . getExclude ( ) ;
}
List < String > excludes = new ArrayList < String > ( ) ;
for ( Map . Entry < String , Object > entry : properties . entrySet ( ) ) {
String name = entry . getKey ( ) ;
Object value = entry . getValue ( ) ;
if ( name . isEmpty ( ) | | name . startsWith ( "[" ) & & value ! = null ) {
excludes . addAll (
StringUtils . commaDelimitedListToSet ( String . valueOf ( value ) ) ) ;
}
}
return excludes ;
}
}
RelaxedPropertyResolver resolver = new RelaxedPropertyResolver ( getEnvironment ( ) ,
RelaxedPropertyResolver resolver = new RelaxedPropertyResolver ( getEnvironment ( ) ,
"spring.autoconfigure." ) ;
"spring.autoconfigure." ) ;
@ -317,21 +328,4 @@ public class AutoConfigurationImportSelector
return Ordered . LOWEST_PRECEDENCE - 1 ;
return Ordered . LOWEST_PRECEDENCE - 1 ;
}
}
/ * *
* Bindable object used to get excludes .
* /
static class Excludes {
private List < String > exclude = new ArrayList < String > ( ) ;
public List < String > getExclude ( ) {
return this . exclude ;
}
public void setExclude ( List < String > excludes ) {
this . exclude = excludes ;
}
}
}
}