Merge branch '1.5.x'
This commit is contained in:
commit
8ffaa54e74
|
@ -143,7 +143,7 @@
|
|||
name="spring-boot-tools">
|
||||
<predicate
|
||||
xsi:type="predicates:NamePredicate"
|
||||
pattern="spring-boot-(tools|antlib|configuration-.*|loader|.*-tools|.*-plugin)"/>
|
||||
pattern="spring-boot-(tools|antlib|configuration-.*|loader|.*-tools|.*-plugin|autoconfigure-processor)"/>
|
||||
</workingSet>
|
||||
<workingSet
|
||||
name="spring-boot-starters">
|
||||
|
|
|
@ -265,6 +265,11 @@
|
|||
<optional>true</optional>
|
||||
</dependency>
|
||||
<!-- Annotation processing -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-autoconfigure-processor</artifactId>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-configuration-processor</artifactId>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2012-2016 the original author or authors.
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -39,13 +39,13 @@ import org.springframework.boot.actuate.endpoint.Endpoint;
|
|||
import org.springframework.boot.actuate.endpoint.mvc.ManagementServletContext;
|
||||
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
|
||||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionMessage;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionOutcome;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
|
||||
import org.springframework.boot.autoconfigure.condition.SpringBootCondition;
|
||||
import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.data.rest.RepositoryRestMvcAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.hateoas.HypermediaAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.web.DispatcherServletAutoConfiguration;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2012-2016 the original author or authors.
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -29,7 +29,7 @@ import org.springframework.beans.factory.NoSuchBeanDefinitionException;
|
|||
import org.springframework.boot.actuate.endpoint.AbstractEndpoint;
|
||||
import org.springframework.boot.actuate.endpoint.Endpoint;
|
||||
import org.springframework.boot.actuate.endpoint.jmx.EndpointMBeanExporter;
|
||||
import org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.jmx.JmxAutoConfiguration;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2012-2016 the original author or authors.
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -38,8 +38,8 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|||
import org.springframework.boot.actuate.endpoint.Endpoint;
|
||||
import org.springframework.boot.actuate.endpoint.mvc.EndpointHandlerMapping;
|
||||
import org.springframework.boot.actuate.endpoint.mvc.EndpointHandlerMappingCustomizer;
|
||||
import org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
||||
import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.web.DispatcherServletAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.web.EmbeddedServletContainerAutoConfiguration;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2012-2016 the original author or authors.
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -53,7 +53,7 @@ import org.springframework.boot.actuate.endpoint.mvc.LoggersMvcEndpoint;
|
|||
import org.springframework.boot.actuate.endpoint.mvc.MetricsMvcEndpoint;
|
||||
import org.springframework.boot.actuate.endpoint.mvc.MvcEndpoint;
|
||||
import org.springframework.boot.actuate.endpoint.mvc.ShutdownMvcEndpoint;
|
||||
import org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.web.DispatcherServletAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.web.EmbeddedServletContainerAutoConfiguration;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2012-2016 the original author or authors.
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -24,7 +24,7 @@ import org.junit.Test;
|
|||
|
||||
import org.springframework.boot.actuate.endpoint.mvc.EndpointHandlerMapping;
|
||||
import org.springframework.boot.actuate.endpoint.mvc.MvcEndpointSecurityInterceptor;
|
||||
import org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.security.SecurityAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.web.HttpMessageConvertersAutoConfiguration;
|
||||
|
|
|
@ -41,8 +41,8 @@ import org.springframework.boot.actuate.health.MongoHealthIndicator;
|
|||
import org.springframework.boot.actuate.health.RabbitHealthIndicator;
|
||||
import org.springframework.boot.actuate.health.RedisHealthIndicator;
|
||||
import org.springframework.boot.actuate.health.SolrHealthIndicator;
|
||||
import org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.amqp.RabbitAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.data.elasticsearch.ElasticsearchAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.data.mongo.MongoDataAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.data.redis.RedisAutoConfiguration;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2012-2016 the original author or authors.
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -27,7 +27,7 @@ import org.springframework.boot.actuate.endpoint.mvc.EndpointHandlerMapping;
|
|||
import org.springframework.boot.actuate.endpoint.mvc.JolokiaMvcEndpoint;
|
||||
import org.springframework.boot.actuate.endpoint.mvc.MvcEndpoint;
|
||||
import org.springframework.boot.actuate.endpoint.mvc.MvcEndpointSecurityInterceptor;
|
||||
import org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.web.HttpMessageConvertersAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.web.WebMvcAutoConfiguration;
|
||||
import org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2012-2016 the original author or authors.
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -26,7 +26,7 @@ import org.junit.Test;
|
|||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.autoconfigure.ImportAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.security.FallbackWebSecurityAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.security.SecurityAutoConfiguration;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2012-2016 the original author or authors.
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -33,7 +33,7 @@ import org.springframework.boot.actuate.metrics.export.MetricExporters;
|
|||
import org.springframework.boot.actuate.metrics.statsd.StatsdMetricWriter;
|
||||
import org.springframework.boot.actuate.metrics.writer.GaugeWriter;
|
||||
import org.springframework.boot.actuate.metrics.writer.MetricWriter;
|
||||
import org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration;
|
||||
import org.springframework.boot.test.util.EnvironmentTestUtils;
|
||||
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2012-2016 the original author or authors.
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -23,7 +23,7 @@ import java.lang.annotation.RetentionPolicy;
|
|||
import java.lang.annotation.Target;
|
||||
|
||||
import org.springframework.boot.autoconfigure.ImportAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.hateoas.HypermediaAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.web.DispatcherServletAutoConfiguration;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2012-2016 the original author or authors.
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -23,7 +23,7 @@ import org.junit.Test;
|
|||
import org.springframework.boot.actuate.trace.TraceProperties;
|
||||
import org.springframework.boot.actuate.trace.TraceRepository;
|
||||
import org.springframework.boot.actuate.trace.WebRequestTraceFilter;
|
||||
import org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration;
|
||||
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2012-2016 the original author or authors.
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -28,7 +28,7 @@ import org.springframework.boot.actuate.autoconfigure.EndpointWebMvcAutoConfigur
|
|||
import org.springframework.boot.actuate.autoconfigure.EndpointWebMvcManagementContextConfiguration;
|
||||
import org.springframework.boot.actuate.autoconfigure.ManagementServerPropertiesAutoConfiguration;
|
||||
import org.springframework.boot.actuate.autoconfigure.ManagementWebSecurityAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.security.IgnoredRequestCustomizer;
|
||||
import org.springframework.boot.autoconfigure.security.SecurityAutoConfiguration;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2012-2016 the original author or authors.
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -24,7 +24,7 @@ import org.springframework.boot.actuate.autoconfigure.EndpointAutoConfiguration;
|
|||
import org.springframework.boot.actuate.autoconfigure.EndpointWebMvcAutoConfiguration;
|
||||
import org.springframework.boot.actuate.autoconfigure.JolokiaAutoConfiguration;
|
||||
import org.springframework.boot.actuate.autoconfigure.ManagementServerPropertiesAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.web.HttpMessageConvertersAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.web.WebMvcAutoConfiguration;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2012-2016 the original author or authors.
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -25,7 +25,7 @@ import org.springframework.boot.actuate.autoconfigure.EndpointWebMvcAutoConfigur
|
|||
import org.springframework.boot.actuate.autoconfigure.ManagementServerPropertiesAutoConfiguration;
|
||||
import org.springframework.boot.actuate.autoconfigure.ManagementWebSecurityAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.ImportAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.data.rest.RepositoryRestMvcAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.hateoas.HypermediaAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2012-2016 the original author or authors.
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -26,7 +26,7 @@ import org.springframework.boot.actuate.autoconfigure.ManagementServerProperties
|
|||
import org.springframework.boot.actuate.health.Health;
|
||||
import org.springframework.boot.actuate.health.HealthIndicator;
|
||||
import org.springframework.boot.autoconfigure.ImportAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.web.HttpMessageConvertersAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.web.WebMvcAutoConfiguration;
|
||||
|
|
|
@ -22,7 +22,7 @@ import org.junit.Test;
|
|||
|
||||
import org.springframework.boot.actuate.autoconfigure.EndpointAutoConfiguration;
|
||||
import org.springframework.boot.actuate.autoconfigure.HealthIndicatorAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.data.ldap.LdapDataAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.ldap.LdapAutoConfiguration;
|
||||
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
|
||||
|
|
|
@ -23,7 +23,7 @@ import org.junit.Test;
|
|||
|
||||
import org.springframework.boot.actuate.autoconfigure.EndpointAutoConfiguration;
|
||||
import org.springframework.boot.actuate.autoconfigure.HealthIndicatorAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.data.mongo.MongoDataAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.mongo.MongoAutoConfiguration;
|
||||
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2012-2016 the original author or authors.
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -22,8 +22,8 @@ import org.junit.Test;
|
|||
import org.springframework.amqp.rabbit.core.RabbitAdmin;
|
||||
import org.springframework.boot.actuate.autoconfigure.EndpointAutoConfiguration;
|
||||
import org.springframework.boot.actuate.autoconfigure.HealthIndicatorAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.amqp.RabbitAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration;
|
||||
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2012-2016 the original author or authors.
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -25,7 +25,7 @@ import org.junit.Test;
|
|||
|
||||
import org.springframework.boot.actuate.autoconfigure.EndpointAutoConfiguration;
|
||||
import org.springframework.boot.actuate.autoconfigure.HealthIndicatorAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.data.redis.RedisAutoConfiguration;
|
||||
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
|
||||
import org.springframework.data.redis.RedisConnectionFailureException;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2012-2016 the original author or authors.
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -26,7 +26,7 @@ import org.junit.Test;
|
|||
|
||||
import org.springframework.boot.actuate.autoconfigure.EndpointAutoConfiguration;
|
||||
import org.springframework.boot.actuate.autoconfigure.HealthIndicatorAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.solr.SolrAutoConfiguration;
|
||||
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
|
||||
|
||||
|
|
|
@ -622,6 +622,11 @@
|
|||
<optional>true</optional>
|
||||
</dependency>
|
||||
<!-- Annotation processing -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-autoconfigure-processor</artifactId>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-configuration-processor</artifactId>
|
||||
|
|
|
@ -0,0 +1,61 @@
|
|||
/*
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.boot.autoconfigure;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.EventObject;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* Event fired when auto-configuration classes are imported.
|
||||
*
|
||||
* @author Phillip Webb
|
||||
* @since 1.5.0
|
||||
*/
|
||||
public class AutoConfigurationImportEvent extends EventObject {
|
||||
|
||||
private final List<String> candidateConfigurations;
|
||||
|
||||
private final Set<String> exclusions;
|
||||
|
||||
public AutoConfigurationImportEvent(Object source,
|
||||
List<String> candidateConfigurations, Set<String> exclusions) {
|
||||
super(source);
|
||||
this.candidateConfigurations = Collections
|
||||
.unmodifiableList(candidateConfigurations);
|
||||
this.exclusions = Collections.unmodifiableSet(exclusions);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the auto-configuration candidate configurations that are going to be
|
||||
* imported.
|
||||
* @return the configurations the auto-configuration candidates
|
||||
*/
|
||||
public List<String> getCandidateConfigurations() {
|
||||
return this.candidateConfigurations;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the exclusions that were applied.
|
||||
* @return the exclusions the exclusions applied
|
||||
*/
|
||||
public Set<String> getExclusions() {
|
||||
return this.exclusions;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,58 @@
|
|||
/*
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.boot.autoconfigure;
|
||||
|
||||
import org.springframework.beans.factory.BeanClassLoaderAware;
|
||||
import org.springframework.beans.factory.BeanFactoryAware;
|
||||
import org.springframework.context.EnvironmentAware;
|
||||
import org.springframework.context.ResourceLoaderAware;
|
||||
|
||||
/**
|
||||
* Filter that can be registered in {@code spring.factories} to limit the
|
||||
* auto-configuration classes considered. This interface is designed to allow fast removal
|
||||
* of auto-configuration classes before their bytecode is even read.
|
||||
* <p>
|
||||
* An {@link AutoConfigurationImportFilter} may implement any of the following
|
||||
* {@link org.springframework.beans.factory.Aware Aware} interfaces, and their respective
|
||||
* methods will be called prior to {@link #match}:
|
||||
* <ul>
|
||||
* <li>{@link EnvironmentAware}</li>
|
||||
* <li>{@link BeanFactoryAware }</li>
|
||||
* <li>{@link BeanClassLoaderAware }</li>
|
||||
* <li>{@link ResourceLoaderAware}</li>
|
||||
* </ul>
|
||||
*
|
||||
* @author Phillip Webb
|
||||
* @since 1.5.0
|
||||
*/
|
||||
public interface AutoConfigurationImportFilter {
|
||||
|
||||
/**
|
||||
* Apply the filter to the given auto-configuration class candidates.
|
||||
* @param autoConfigurationClasses the auto-configuration classes being considered.
|
||||
* Implementations should not change the values in this array.
|
||||
* @param autoConfigurationMetadata access to the meta-data generated by the
|
||||
* auto-configure annotation processor
|
||||
* @return a boolean array indicating which of the auto-configuration classes should
|
||||
* be imported. The returned array must be the same size as the incoming
|
||||
* {@code autoConfigurationClasses} parameter. Entries containing {@code false} will
|
||||
* not be imported.
|
||||
*/
|
||||
boolean[] match(String[] autoConfigurationClasses,
|
||||
AutoConfigurationMetadata autoConfigurationMetadata);
|
||||
|
||||
}
|
|
@ -0,0 +1,52 @@
|
|||
/*
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.boot.autoconfigure;
|
||||
|
||||
import java.util.EventListener;
|
||||
|
||||
import org.springframework.beans.factory.BeanClassLoaderAware;
|
||||
import org.springframework.beans.factory.BeanFactoryAware;
|
||||
import org.springframework.context.EnvironmentAware;
|
||||
import org.springframework.context.ResourceLoaderAware;
|
||||
|
||||
/**
|
||||
* Listener that can be registered with {@code spring.factories} to receive details of
|
||||
* imported auto-configurations.
|
||||
* <p>
|
||||
* An {@link AutoConfigurationImportListener} may implement any of the following
|
||||
* {@link org.springframework.beans.factory.Aware Aware} interfaces, and their respective
|
||||
* methods will be called prior to
|
||||
* {@link #onAutoConfigurationImportEvent(AutoConfigurationImportEvent)}:
|
||||
* <ul>
|
||||
* <li>{@link EnvironmentAware}</li>
|
||||
* <li>{@link BeanFactoryAware }</li>
|
||||
* <li>{@link BeanClassLoaderAware }</li>
|
||||
* <li>{@link ResourceLoaderAware}</li>
|
||||
* </ul>
|
||||
*
|
||||
* @author Phillip Webb
|
||||
* @since 1.5.0
|
||||
*/
|
||||
public interface AutoConfigurationImportListener extends EventListener {
|
||||
|
||||
/**
|
||||
* Handle an auto-configuration import event.
|
||||
* @param event the event to respond to
|
||||
*/
|
||||
void onAutoConfigurationImportEvent(AutoConfigurationImportEvent event);
|
||||
|
||||
}
|
|
@ -0,0 +1,381 @@
|
|||
/*
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.boot.autoconfigure;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import org.springframework.beans.BeansException;
|
||||
import org.springframework.beans.factory.Aware;
|
||||
import org.springframework.beans.factory.BeanClassLoaderAware;
|
||||
import org.springframework.beans.factory.BeanFactory;
|
||||
import org.springframework.beans.factory.BeanFactoryAware;
|
||||
import org.springframework.beans.factory.NoSuchBeanDefinitionException;
|
||||
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
|
||||
import org.springframework.boot.bind.RelaxedPropertyResolver;
|
||||
import org.springframework.context.EnvironmentAware;
|
||||
import org.springframework.context.ResourceLoaderAware;
|
||||
import org.springframework.context.annotation.DeferredImportSelector;
|
||||
import org.springframework.core.Ordered;
|
||||
import org.springframework.core.annotation.AnnotationAttributes;
|
||||
import org.springframework.core.env.ConfigurableEnvironment;
|
||||
import org.springframework.core.env.Environment;
|
||||
import org.springframework.core.io.ResourceLoader;
|
||||
import org.springframework.core.io.support.SpringFactoriesLoader;
|
||||
import org.springframework.core.type.AnnotationMetadata;
|
||||
import org.springframework.core.type.classreading.CachingMetadataReaderFactory;
|
||||
import org.springframework.core.type.classreading.MetadataReaderFactory;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.ClassUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
* {@link DeferredImportSelector} to handle {@link EnableAutoConfiguration
|
||||
* auto-configuration}. This class can also be subclassed if a custom variant of
|
||||
* {@link EnableAutoConfiguration @EnableAutoConfiguration}. is needed.
|
||||
*
|
||||
* @author Phillip Webb
|
||||
* @author Andy Wilkinson
|
||||
* @author Stephane Nicoll
|
||||
* @author Madhura Bhave
|
||||
* @since 1.3.0
|
||||
* @see EnableAutoConfiguration
|
||||
*/
|
||||
public class AutoConfigurationImportSelector
|
||||
implements DeferredImportSelector, BeanClassLoaderAware, ResourceLoaderAware,
|
||||
BeanFactoryAware, EnvironmentAware, Ordered {
|
||||
|
||||
private static final String[] NO_IMPORTS = {};
|
||||
|
||||
private static final Log logger = LogFactory
|
||||
.getLog(AutoConfigurationImportSelector.class);
|
||||
|
||||
private ConfigurableListableBeanFactory beanFactory;
|
||||
|
||||
private Environment environment;
|
||||
|
||||
private ClassLoader beanClassLoader;
|
||||
|
||||
private ResourceLoader resourceLoader;
|
||||
|
||||
@Override
|
||||
public String[] selectImports(AnnotationMetadata annotationMetadata) {
|
||||
if (!isEnabled(annotationMetadata)) {
|
||||
return NO_IMPORTS;
|
||||
}
|
||||
try {
|
||||
AutoConfigurationMetadata autoConfigurationMetadata = AutoConfigurationMetadataLoader
|
||||
.loadMetadata(this.beanClassLoader);
|
||||
AnnotationAttributes attributes = getAttributes(annotationMetadata);
|
||||
List<String> configurations = getCandidateConfigurations(annotationMetadata,
|
||||
attributes);
|
||||
configurations = removeDuplicates(configurations);
|
||||
configurations = sort(configurations, autoConfigurationMetadata);
|
||||
Set<String> exclusions = getExclusions(annotationMetadata, attributes);
|
||||
checkExcludedClasses(configurations, exclusions);
|
||||
configurations.removeAll(exclusions);
|
||||
configurations = filter(configurations, autoConfigurationMetadata);
|
||||
fireAutoConfigurationImportListeners(configurations, exclusions);
|
||||
return configurations.toArray(new String[configurations.size()]);
|
||||
}
|
||||
catch (IOException ex) {
|
||||
throw new IllegalStateException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
protected boolean isEnabled(AnnotationMetadata metadata) {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the appropriate {@link AnnotationAttributes} from the
|
||||
* {@link AnnotationMetadata}. By default this method will return attributes for
|
||||
* {@link #getAnnotationClass()}.
|
||||
* @param metadata the annotation metadata
|
||||
* @return annotation attributes
|
||||
*/
|
||||
protected AnnotationAttributes getAttributes(AnnotationMetadata metadata) {
|
||||
String name = getAnnotationClass().getName();
|
||||
AnnotationAttributes attributes = AnnotationAttributes
|
||||
.fromMap(metadata.getAnnotationAttributes(name, true));
|
||||
Assert.notNull(attributes,
|
||||
"No auto-configuration attributes found. Is " + metadata.getClassName()
|
||||
+ " annotated with " + ClassUtils.getShortName(name) + "?");
|
||||
return attributes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the source annotation class used by the selector.
|
||||
* @return the annotation class
|
||||
*/
|
||||
protected Class<?> getAnnotationClass() {
|
||||
return EnableAutoConfiguration.class;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the auto-configuration class names that should be considered. By default
|
||||
* this method will load candidates using {@link SpringFactoriesLoader} with
|
||||
* {@link #getSpringFactoriesLoaderFactoryClass()}.
|
||||
* @param metadata the source metadata
|
||||
* @param attributes the {@link #getAttributes(AnnotationMetadata) annotation
|
||||
* attributes}
|
||||
* @return a list of candidate configurations
|
||||
*/
|
||||
protected List<String> getCandidateConfigurations(AnnotationMetadata metadata,
|
||||
AnnotationAttributes attributes) {
|
||||
List<String> configurations = SpringFactoriesLoader.loadFactoryNames(
|
||||
getSpringFactoriesLoaderFactoryClass(), getBeanClassLoader());
|
||||
Assert.notEmpty(configurations,
|
||||
"No auto configuration classes found in META-INF/spring.factories. If you "
|
||||
+ "are using a custom packaging, make sure that file is correct.");
|
||||
return configurations;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the class used by {@link SpringFactoriesLoader} to load configuration
|
||||
* candidates.
|
||||
* @return the factory class
|
||||
*/
|
||||
protected Class<?> getSpringFactoriesLoaderFactoryClass() {
|
||||
return EnableAutoConfiguration.class;
|
||||
}
|
||||
|
||||
private void checkExcludedClasses(List<String> configurations,
|
||||
Set<String> exclusions) {
|
||||
List<String> invalidExcludes = new ArrayList<String>(exclusions.size());
|
||||
for (String exclusion : exclusions) {
|
||||
if (ClassUtils.isPresent(exclusion, getClass().getClassLoader())
|
||||
&& !configurations.contains(exclusion)) {
|
||||
invalidExcludes.add(exclusion);
|
||||
}
|
||||
}
|
||||
if (!invalidExcludes.isEmpty()) {
|
||||
handleInvalidExcludes(invalidExcludes);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle any invalid excludes that have been specified.
|
||||
* @param invalidExcludes the list of invalid excludes (will always have at least one
|
||||
* element)
|
||||
*/
|
||||
protected void handleInvalidExcludes(List<String> invalidExcludes) {
|
||||
StringBuilder message = new StringBuilder();
|
||||
for (String exclude : invalidExcludes) {
|
||||
message.append("\t- ").append(exclude).append(String.format("%n"));
|
||||
}
|
||||
throw new IllegalStateException(String
|
||||
.format("The following classes could not be excluded because they are"
|
||||
+ " not auto-configuration classes:%n%s", message));
|
||||
}
|
||||
|
||||
/**
|
||||
* Return any exclusions that limit the candidate configurations.
|
||||
* @param metadata the source metadata
|
||||
* @param attributes the {@link #getAttributes(AnnotationMetadata) annotation
|
||||
* attributes}
|
||||
* @return exclusions or an empty set
|
||||
*/
|
||||
protected Set<String> getExclusions(AnnotationMetadata metadata,
|
||||
AnnotationAttributes attributes) {
|
||||
Set<String> excluded = new LinkedHashSet<String>();
|
||||
excluded.addAll(asList(attributes, "exclude"));
|
||||
excluded.addAll(Arrays.asList(attributes.getStringArray("excludeName")));
|
||||
excluded.addAll(getExcludeAutoConfigurationsProperty());
|
||||
return excluded;
|
||||
}
|
||||
|
||||
private List<String> getExcludeAutoConfigurationsProperty() {
|
||||
if (getEnvironment() instanceof ConfigurableEnvironment) {
|
||||
RelaxedPropertyResolver resolver = new RelaxedPropertyResolver(
|
||||
this.environment, "spring.autoconfigure.");
|
||||
Map<String, Object> properties = resolver.getSubProperties("exclude");
|
||||
if (properties.isEmpty()) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
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(),
|
||||
"spring.autoconfigure.");
|
||||
String[] exclude = resolver.getProperty("exclude", String[].class);
|
||||
return (Arrays.asList(exclude == null ? new String[0] : exclude));
|
||||
}
|
||||
|
||||
private List<String> sort(List<String> configurations,
|
||||
AutoConfigurationMetadata autoConfigurationMetadata) throws IOException {
|
||||
configurations = new AutoConfigurationSorter(getMetadataReaderFactory(),
|
||||
autoConfigurationMetadata).getInPriorityOrder(configurations);
|
||||
return configurations;
|
||||
}
|
||||
|
||||
private List<String> filter(List<String> configurations,
|
||||
AutoConfigurationMetadata autoConfigurationMetadata) {
|
||||
long startTime = System.nanoTime();
|
||||
String[] candidates = configurations.toArray(new String[configurations.size()]);
|
||||
boolean[] skip = new boolean[candidates.length];
|
||||
boolean skipped = false;
|
||||
for (AutoConfigurationImportFilter filter : getAutoConfigurationImportFilters()) {
|
||||
invokeAwareMethods(filter);
|
||||
boolean[] match = filter.match(candidates, autoConfigurationMetadata);
|
||||
for (int i = 0; i < match.length; i++) {
|
||||
if (!match[i]) {
|
||||
skip[i] = true;
|
||||
skipped = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!skipped) {
|
||||
return configurations;
|
||||
}
|
||||
List<String> result = new ArrayList<String>(candidates.length);
|
||||
for (int i = 0; i < candidates.length; i++) {
|
||||
if (!skip[i]) {
|
||||
result.add(candidates[i]);
|
||||
}
|
||||
}
|
||||
if (logger.isTraceEnabled()) {
|
||||
int numberFiltered = configurations.size() - result.size();
|
||||
logger.trace("Filtered " + numberFiltered + " auto configuration class in "
|
||||
+ TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - startTime)
|
||||
+ " ms");
|
||||
}
|
||||
return new ArrayList<String>(result);
|
||||
}
|
||||
|
||||
protected List<AutoConfigurationImportFilter> getAutoConfigurationImportFilters() {
|
||||
return SpringFactoriesLoader.loadFactories(AutoConfigurationImportFilter.class,
|
||||
this.beanClassLoader);
|
||||
}
|
||||
|
||||
private MetadataReaderFactory getMetadataReaderFactory() {
|
||||
try {
|
||||
return getBeanFactory().getBean(
|
||||
SharedMetadataReaderFactoryContextInitializer.BEAN_NAME,
|
||||
MetadataReaderFactory.class);
|
||||
}
|
||||
catch (NoSuchBeanDefinitionException ex) {
|
||||
return new CachingMetadataReaderFactory(this.resourceLoader);
|
||||
}
|
||||
}
|
||||
|
||||
protected final <T> List<T> removeDuplicates(List<T> list) {
|
||||
return new ArrayList<T>(new LinkedHashSet<T>(list));
|
||||
}
|
||||
|
||||
protected final List<String> asList(AnnotationAttributes attributes, String name) {
|
||||
String[] value = attributes.getStringArray(name);
|
||||
return Arrays.asList(value == null ? new String[0] : value);
|
||||
}
|
||||
|
||||
private void fireAutoConfigurationImportListeners(List<String> configurations,
|
||||
Set<String> exclusions) {
|
||||
List<AutoConfigurationImportListener> listeners = getAutoConfigurationImportListeners();
|
||||
if (!listeners.isEmpty()) {
|
||||
AutoConfigurationImportEvent event = new AutoConfigurationImportEvent(this,
|
||||
configurations, exclusions);
|
||||
for (AutoConfigurationImportListener listener : listeners) {
|
||||
invokeAwareMethods(listener);
|
||||
listener.onAutoConfigurationImportEvent(event);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected List<AutoConfigurationImportListener> getAutoConfigurationImportListeners() {
|
||||
return SpringFactoriesLoader.loadFactories(AutoConfigurationImportListener.class,
|
||||
this.beanClassLoader);
|
||||
}
|
||||
|
||||
private void invokeAwareMethods(Object instance) {
|
||||
if (instance instanceof Aware) {
|
||||
if (instance instanceof BeanClassLoaderAware) {
|
||||
((BeanClassLoaderAware) instance)
|
||||
.setBeanClassLoader(this.beanClassLoader);
|
||||
}
|
||||
if (instance instanceof BeanFactoryAware) {
|
||||
((BeanFactoryAware) instance).setBeanFactory(this.beanFactory);
|
||||
}
|
||||
if (instance instanceof EnvironmentAware) {
|
||||
((EnvironmentAware) instance).setEnvironment(this.environment);
|
||||
}
|
||||
if (instance instanceof ResourceLoaderAware) {
|
||||
((ResourceLoaderAware) instance).setResourceLoader(this.resourceLoader);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBeanFactory(BeanFactory beanFactory) throws BeansException {
|
||||
Assert.isInstanceOf(ConfigurableListableBeanFactory.class, beanFactory);
|
||||
this.beanFactory = (ConfigurableListableBeanFactory) beanFactory;
|
||||
}
|
||||
|
||||
protected final ConfigurableListableBeanFactory getBeanFactory() {
|
||||
return this.beanFactory;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBeanClassLoader(ClassLoader classLoader) {
|
||||
this.beanClassLoader = classLoader;
|
||||
}
|
||||
|
||||
protected ClassLoader getBeanClassLoader() {
|
||||
return this.beanClassLoader;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setEnvironment(Environment environment) {
|
||||
this.environment = environment;
|
||||
}
|
||||
|
||||
protected final Environment getEnvironment() {
|
||||
return this.environment;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setResourceLoader(ResourceLoader resourceLoader) {
|
||||
this.resourceLoader = resourceLoader;
|
||||
}
|
||||
|
||||
protected final ResourceLoader getResourceLoader() {
|
||||
return this.resourceLoader;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getOrder() {
|
||||
return Ordered.LOWEST_PRECEDENCE - 1;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,88 @@
|
|||
/*
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.boot.autoconfigure;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* Provides access to meta-data written by the auto-configure annotation processor.
|
||||
*
|
||||
* @author Phillip Webb
|
||||
* @since 1.5.0
|
||||
*/
|
||||
public interface AutoConfigurationMetadata {
|
||||
|
||||
/**
|
||||
* Return {@code true} if the specified class name was processed by the annotation
|
||||
* processor.
|
||||
* @param className the source class
|
||||
* @return if the class was processed
|
||||
*/
|
||||
boolean wasProcessed(String className);
|
||||
|
||||
/**
|
||||
* Get an {@link Integer} value from the meta-data.
|
||||
* @param className the source class
|
||||
* @param key the meta-data key
|
||||
* @return the meta-data value or {@code null}
|
||||
*/
|
||||
Integer getInteger(String className, String key);
|
||||
|
||||
/**
|
||||
* Get an {@link Integer} value from the meta-data.
|
||||
* @param className the source class
|
||||
* @param key the meta-data key
|
||||
* @param defaultValue the default value
|
||||
* @return the meta-data value or {@code defaultValue}
|
||||
*/
|
||||
Integer getInteger(String className, String key, Integer defaultValue);
|
||||
|
||||
/**
|
||||
* Get a {@link Set} value from the meta-data.
|
||||
* @param className the source class
|
||||
* @param key the meta-data key
|
||||
* @return the meta-data value or {@code null}
|
||||
*/
|
||||
Set<String> getSet(String className, String key);
|
||||
|
||||
/**
|
||||
* Get a {@link Set} value from the meta-data.
|
||||
* @param className the source class
|
||||
* @param key the meta-data key
|
||||
* @param defaultValue the default value
|
||||
* @return the meta-data value or {@code defaultValue}
|
||||
*/
|
||||
Set<String> getSet(String className, String key, Set<String> defaultValue);
|
||||
|
||||
/**
|
||||
* Get an {@link String} value from the meta-data.
|
||||
* @param className the source class
|
||||
* @param key the meta-data key
|
||||
* @return the meta-data value or {@code null}
|
||||
*/
|
||||
String get(String className, String key);
|
||||
|
||||
/**
|
||||
* Get an {@link String} value from the meta-data.
|
||||
* @param className the source class
|
||||
* @param key the meta-data key
|
||||
* @param defaultValue the default value
|
||||
* @return the meta-data value or {@code defaultValue}
|
||||
*/
|
||||
String get(String className, String key, String defaultValue);
|
||||
|
||||
}
|
|
@ -0,0 +1,121 @@
|
|||
/*
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.boot.autoconfigure;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
import java.util.Enumeration;
|
||||
import java.util.Properties;
|
||||
import java.util.Set;
|
||||
|
||||
import org.springframework.core.io.UrlResource;
|
||||
import org.springframework.core.io.support.PropertiesLoaderUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
* Internal utility used to load {@link AutoConfigurationMetadata}.
|
||||
*
|
||||
* @author Phillip Webb
|
||||
*/
|
||||
final class AutoConfigurationMetadataLoader {
|
||||
|
||||
protected static final String PATH = "META-INF/"
|
||||
+ "spring-autoconfigure-metadata.properties";
|
||||
|
||||
private AutoConfigurationMetadataLoader() {
|
||||
}
|
||||
|
||||
public static AutoConfigurationMetadata loadMetadata(ClassLoader classLoader) {
|
||||
return loadMetadata(classLoader, PATH);
|
||||
}
|
||||
|
||||
static AutoConfigurationMetadata loadMetadata(ClassLoader classLoader, String path) {
|
||||
try {
|
||||
Enumeration<URL> urls = (classLoader != null ? classLoader.getResources(path)
|
||||
: ClassLoader.getSystemResources(path));
|
||||
Properties properties = new Properties();
|
||||
while (urls.hasMoreElements()) {
|
||||
properties.putAll(PropertiesLoaderUtils
|
||||
.loadProperties(new UrlResource(urls.nextElement())));
|
||||
}
|
||||
return loadMetadata(properties);
|
||||
}
|
||||
catch (IOException ex) {
|
||||
throw new IllegalArgumentException(
|
||||
"Unable to load @ConditionalOnClass location [" + path + "]", ex);
|
||||
}
|
||||
}
|
||||
|
||||
static AutoConfigurationMetadata loadMetadata(Properties properties) {
|
||||
return new PropertiesAutoConfigurationMetadata(properties);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@link AutoConfigurationMetadata} implementation backed by a properties file.
|
||||
*/
|
||||
private static class PropertiesAutoConfigurationMetadata
|
||||
implements AutoConfigurationMetadata {
|
||||
|
||||
private final Properties properties;
|
||||
|
||||
PropertiesAutoConfigurationMetadata(Properties properties) {
|
||||
this.properties = properties;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean wasProcessed(String className) {
|
||||
return this.properties.containsKey(className);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer getInteger(String className, String key) {
|
||||
return getInteger(className, key, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer getInteger(String className, String key, Integer defaultValue) {
|
||||
String value = get(className, key);
|
||||
return (value != null ? Integer.valueOf(value) : defaultValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<String> getSet(String className, String key) {
|
||||
return getSet(className, key, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<String> getSet(String className, String key,
|
||||
Set<String> defaultValue) {
|
||||
String value = get(className, key);
|
||||
return (value != null ? StringUtils.commaDelimitedListToSet(value)
|
||||
: defaultValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String get(String className, String key) {
|
||||
return get(className, key, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String get(String className, String key, String defaultValue) {
|
||||
String value = this.properties.getProperty(className + "." + key);
|
||||
return (value != null ? value : defaultValue);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2012-2016 the original author or authors.
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -35,8 +35,8 @@ import org.springframework.util.Assert;
|
|||
|
||||
/**
|
||||
* Sort {@link EnableAutoConfiguration auto-configuration} classes into priority order by
|
||||
* reading {@link Ordered}, {@link AutoConfigureBefore} and {@link AutoConfigureAfter}
|
||||
* annotations (without loading classes).
|
||||
* reading {@link AutoConfigureOrder}, {@link AutoConfigureBefore} and
|
||||
* {@link AutoConfigureAfter} annotations (without loading classes).
|
||||
*
|
||||
* @author Phillip Webb
|
||||
*/
|
||||
|
@ -44,26 +44,31 @@ class AutoConfigurationSorter {
|
|||
|
||||
private final MetadataReaderFactory metadataReaderFactory;
|
||||
|
||||
AutoConfigurationSorter(MetadataReaderFactory metadataReaderFactory) {
|
||||
private final AutoConfigurationMetadata autoConfigurationMetadata;
|
||||
|
||||
AutoConfigurationSorter(MetadataReaderFactory metadataReaderFactory,
|
||||
AutoConfigurationMetadata autoConfigurationMetadata) {
|
||||
Assert.notNull(metadataReaderFactory, "MetadataReaderFactory must not be null");
|
||||
this.metadataReaderFactory = metadataReaderFactory;
|
||||
this.autoConfigurationMetadata = autoConfigurationMetadata;
|
||||
}
|
||||
|
||||
public List<String> getInPriorityOrder(Collection<String> classNames)
|
||||
throws IOException {
|
||||
public List<String> getInPriorityOrder(Collection<String> classNames) {
|
||||
final AutoConfigurationClasses classes = new AutoConfigurationClasses(
|
||||
this.metadataReaderFactory, classNames);
|
||||
this.metadataReaderFactory, this.autoConfigurationMetadata, classNames);
|
||||
List<String> orderedClassNames = new ArrayList<String>(classNames);
|
||||
// Initially sort alphabetically
|
||||
Collections.sort(orderedClassNames);
|
||||
// Then sort by order
|
||||
Collections.sort(orderedClassNames, new Comparator<String>() {
|
||||
|
||||
@Override
|
||||
public int compare(String o1, String o2) {
|
||||
int i1 = classes.get(o1).getOrder();
|
||||
int i2 = classes.get(o2).getOrder();
|
||||
return (i1 < i2) ? -1 : (i1 > i2) ? 1 : 0;
|
||||
}
|
||||
|
||||
});
|
||||
// Then respect @AutoConfigureBefore @AutoConfigureAfter
|
||||
orderedClassNames = sortByAnnotation(classes, orderedClassNames);
|
||||
|
@ -104,11 +109,11 @@ class AutoConfigurationSorter {
|
|||
private final Map<String, AutoConfigurationClass> classes = new HashMap<String, AutoConfigurationClass>();
|
||||
|
||||
AutoConfigurationClasses(MetadataReaderFactory metadataReaderFactory,
|
||||
Collection<String> classNames) throws IOException {
|
||||
AutoConfigurationMetadata autoConfigurationMetadata,
|
||||
Collection<String> classNames) {
|
||||
for (String className : classNames) {
|
||||
MetadataReader metadataReader = metadataReaderFactory
|
||||
.getMetadataReader(className);
|
||||
this.classes.put(className, new AutoConfigurationClass(metadataReader));
|
||||
this.classes.put(className, new AutoConfigurationClass(className,
|
||||
metadataReaderFactory, autoConfigurationMetadata));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -132,29 +137,65 @@ class AutoConfigurationSorter {
|
|||
|
||||
private static class AutoConfigurationClass {
|
||||
|
||||
private final AnnotationMetadata metadata;
|
||||
private final String className;
|
||||
|
||||
AutoConfigurationClass(MetadataReader metadataReader) {
|
||||
this.metadata = metadataReader.getAnnotationMetadata();
|
||||
}
|
||||
private final MetadataReaderFactory metadataReaderFactory;
|
||||
|
||||
public int getOrder() {
|
||||
Map<String, Object> orderedAnnotation = this.metadata
|
||||
.getAnnotationAttributes(AutoConfigureOrder.class.getName());
|
||||
return (orderedAnnotation == null ? Ordered.LOWEST_PRECEDENCE
|
||||
: (Integer) orderedAnnotation.get("value"));
|
||||
private final AutoConfigurationMetadata autoConfigurationMetadata;
|
||||
|
||||
private AnnotationMetadata annotationMetadata;
|
||||
|
||||
private final Set<String> before;
|
||||
|
||||
private final Set<String> after;
|
||||
|
||||
AutoConfigurationClass(String className,
|
||||
MetadataReaderFactory metadataReaderFactory,
|
||||
AutoConfigurationMetadata autoConfigurationMetadata) {
|
||||
this.className = className;
|
||||
this.metadataReaderFactory = metadataReaderFactory;
|
||||
this.autoConfigurationMetadata = autoConfigurationMetadata;
|
||||
this.before = readBefore();
|
||||
this.after = readAfter();
|
||||
}
|
||||
|
||||
public Set<String> getBefore() {
|
||||
return getAnnotationValue(AutoConfigureBefore.class);
|
||||
return this.before;
|
||||
}
|
||||
|
||||
public Set<String> getAfter() {
|
||||
return this.after;
|
||||
}
|
||||
|
||||
private int getOrder() {
|
||||
if (this.autoConfigurationMetadata.wasProcessed(this.className)) {
|
||||
return this.autoConfigurationMetadata.getInteger(this.className,
|
||||
"AutoConfigureOrder", Ordered.LOWEST_PRECEDENCE);
|
||||
}
|
||||
Map<String, Object> attributes = getAnnotationMetadata()
|
||||
.getAnnotationAttributes(AutoConfigureOrder.class.getName());
|
||||
return (attributes == null ? Ordered.LOWEST_PRECEDENCE
|
||||
: (Integer) attributes.get("value"));
|
||||
}
|
||||
|
||||
private Set<String> readBefore() {
|
||||
if (this.autoConfigurationMetadata.wasProcessed(this.className)) {
|
||||
return this.autoConfigurationMetadata.getSet(this.className,
|
||||
"AutoConfigureBefore", Collections.<String>emptySet());
|
||||
}
|
||||
return getAnnotationValue(AutoConfigureBefore.class);
|
||||
}
|
||||
|
||||
private Set<String> readAfter() {
|
||||
if (this.autoConfigurationMetadata.wasProcessed(this.className)) {
|
||||
return this.autoConfigurationMetadata.getSet(this.className,
|
||||
"AutoConfigureAfter", Collections.<String>emptySet());
|
||||
}
|
||||
return getAnnotationValue(AutoConfigureAfter.class);
|
||||
}
|
||||
|
||||
private Set<String> getAnnotationValue(Class<?> annotation) {
|
||||
Map<String, Object> attributes = this.metadata
|
||||
Map<String, Object> attributes = getAnnotationMetadata()
|
||||
.getAnnotationAttributes(annotation.getName(), true);
|
||||
if (attributes == null) {
|
||||
return Collections.emptySet();
|
||||
|
@ -165,6 +206,21 @@ class AutoConfigurationSorter {
|
|||
return value;
|
||||
}
|
||||
|
||||
private AnnotationMetadata getAnnotationMetadata() {
|
||||
if (this.annotationMetadata == null) {
|
||||
try {
|
||||
MetadataReader metadataReader = this.metadataReaderFactory
|
||||
.getMetadataReader(this.className);
|
||||
this.annotationMetadata = metadataReader.getAnnotationMetadata();
|
||||
}
|
||||
catch (IOException ex) {
|
||||
throw new IllegalStateException(
|
||||
"Unable to read meta-data for class " + this.className, ex);
|
||||
}
|
||||
}
|
||||
return this.annotationMetadata;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2012-2016 the original author or authors.
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -67,6 +67,7 @@ import org.springframework.core.io.support.SpringFactoriesLoader;
|
|||
* @see ConditionalOnClass
|
||||
* @see AutoConfigureAfter
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
@Target(ElementType.TYPE)
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Documented
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2012-2016 the original author or authors.
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -16,44 +16,15 @@
|
|||
|
||||
package org.springframework.boot.autoconfigure;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.springframework.beans.BeansException;
|
||||
import org.springframework.beans.factory.BeanClassLoaderAware;
|
||||
import org.springframework.beans.factory.BeanFactory;
|
||||
import org.springframework.beans.factory.BeanFactoryAware;
|
||||
import org.springframework.beans.factory.NoSuchBeanDefinitionException;
|
||||
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionEvaluationReport;
|
||||
import org.springframework.boot.bind.PropertySourcesPropertyValues;
|
||||
import org.springframework.boot.bind.RelaxedDataBinder;
|
||||
import org.springframework.boot.bind.RelaxedPropertyResolver;
|
||||
import org.springframework.context.EnvironmentAware;
|
||||
import org.springframework.context.ResourceLoaderAware;
|
||||
import org.springframework.context.annotation.DeferredImportSelector;
|
||||
import org.springframework.core.Ordered;
|
||||
import org.springframework.core.annotation.AnnotationAttributes;
|
||||
import org.springframework.core.env.ConfigurableEnvironment;
|
||||
import org.springframework.core.env.Environment;
|
||||
import org.springframework.core.io.ResourceLoader;
|
||||
import org.springframework.core.io.support.SpringFactoriesLoader;
|
||||
import org.springframework.core.type.AnnotationMetadata;
|
||||
import org.springframework.core.type.classreading.CachingMetadataReaderFactory;
|
||||
import org.springframework.core.type.classreading.MetadataReaderFactory;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.ClassUtils;
|
||||
|
||||
/**
|
||||
* {@link DeferredImportSelector} to handle {@link EnableAutoConfiguration
|
||||
* auto-configuration}. This class can also be subclassed if a custom variant of
|
||||
* {@link EnableAutoConfiguration @EnableAutoConfiguration}. is needed.
|
||||
*
|
||||
* @deprecated as of 1.5 in favor of {@link AutoConfigurationImportSelector}
|
||||
* @author Phillip Webb
|
||||
* @author Andy Wilkinson
|
||||
* @author Stephane Nicoll
|
||||
|
@ -61,255 +32,18 @@ import org.springframework.util.ClassUtils;
|
|||
* @since 1.3.0
|
||||
* @see EnableAutoConfiguration
|
||||
*/
|
||||
@Deprecated
|
||||
public class EnableAutoConfigurationImportSelector
|
||||
implements DeferredImportSelector, BeanClassLoaderAware, ResourceLoaderAware,
|
||||
BeanFactoryAware, EnvironmentAware, Ordered {
|
||||
|
||||
private static final String[] NO_IMPORTS = {};
|
||||
|
||||
private ConfigurableListableBeanFactory beanFactory;
|
||||
|
||||
private Environment environment;
|
||||
|
||||
private ClassLoader beanClassLoader;
|
||||
|
||||
private ResourceLoader resourceLoader;
|
||||
extends AutoConfigurationImportSelector {
|
||||
|
||||
@Override
|
||||
public String[] selectImports(AnnotationMetadata metadata) {
|
||||
if (!isEnabled(metadata)) {
|
||||
return NO_IMPORTS;
|
||||
}
|
||||
try {
|
||||
AnnotationAttributes attributes = getAttributes(metadata);
|
||||
List<String> configurations = getCandidateConfigurations(metadata,
|
||||
attributes);
|
||||
configurations = removeDuplicates(configurations);
|
||||
Set<String> exclusions = getExclusions(metadata, attributes);
|
||||
checkExcludedClasses(configurations, exclusions);
|
||||
configurations.removeAll(exclusions);
|
||||
configurations = sort(configurations);
|
||||
recordWithConditionEvaluationReport(configurations, exclusions);
|
||||
return configurations.toArray(new String[configurations.size()]);
|
||||
}
|
||||
catch (IOException ex) {
|
||||
throw new IllegalStateException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
protected boolean isEnabled(AnnotationMetadata metadata) {
|
||||
if (getClass().equals(EnableAutoConfigurationImportSelector.class)) {
|
||||
return this.environment.getProperty(
|
||||
return getEnvironment().getProperty(
|
||||
EnableAutoConfiguration.ENABLED_OVERRIDE_PROPERTY, Boolean.class,
|
||||
true);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the appropriate {@link AnnotationAttributes} from the
|
||||
* {@link AnnotationMetadata}. By default this method will return attributes for
|
||||
* {@link #getAnnotationClass()}.
|
||||
* @param metadata the annotation metadata
|
||||
* @return annotation attributes
|
||||
*/
|
||||
protected AnnotationAttributes getAttributes(AnnotationMetadata metadata) {
|
||||
String name = getAnnotationClass().getName();
|
||||
AnnotationAttributes attributes = AnnotationAttributes
|
||||
.fromMap(metadata.getAnnotationAttributes(name, true));
|
||||
Assert.notNull(attributes,
|
||||
"No auto-configuration attributes found. Is " + metadata.getClassName()
|
||||
+ " annotated with " + ClassUtils.getShortName(name) + "?");
|
||||
return attributes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the source annotation class used by the selector.
|
||||
* @return the annotation class
|
||||
*/
|
||||
protected Class<?> getAnnotationClass() {
|
||||
return EnableAutoConfiguration.class;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the auto-configuration class names that should be considered. By default
|
||||
* this method will load candidates using {@link SpringFactoriesLoader} with
|
||||
* {@link #getSpringFactoriesLoaderFactoryClass()}.
|
||||
* @param metadata the source metadata
|
||||
* @param attributes the {@link #getAttributes(AnnotationMetadata) annotation
|
||||
* attributes}
|
||||
* @return a list of candidate configurations
|
||||
*/
|
||||
protected List<String> getCandidateConfigurations(AnnotationMetadata metadata,
|
||||
AnnotationAttributes attributes) {
|
||||
List<String> configurations = SpringFactoriesLoader.loadFactoryNames(
|
||||
getSpringFactoriesLoaderFactoryClass(), getBeanClassLoader());
|
||||
Assert.notEmpty(configurations,
|
||||
"No auto configuration classes found in META-INF/spring.factories. If you "
|
||||
+ "are using a custom packaging, make sure that file is correct.");
|
||||
return configurations;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the class used by {@link SpringFactoriesLoader} to load configuration
|
||||
* candidates.
|
||||
* @return the factory class
|
||||
*/
|
||||
protected Class<?> getSpringFactoriesLoaderFactoryClass() {
|
||||
return EnableAutoConfiguration.class;
|
||||
}
|
||||
|
||||
private void checkExcludedClasses(List<String> configurations,
|
||||
Set<String> exclusions) {
|
||||
List<String> invalidExcludes = new ArrayList<String>();
|
||||
for (String exclusion : exclusions) {
|
||||
if (ClassUtils.isPresent(exclusion, getClass().getClassLoader())
|
||||
&& !configurations.contains(exclusion)) {
|
||||
invalidExcludes.add(exclusion);
|
||||
}
|
||||
}
|
||||
if (!invalidExcludes.isEmpty()) {
|
||||
handleInvalidExcludes(invalidExcludes);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle any invalid excludes that have been specified.
|
||||
* @param invalidExcludes the list of invalid excludes (will always have at least one
|
||||
* element)
|
||||
*/
|
||||
protected void handleInvalidExcludes(List<String> invalidExcludes) {
|
||||
StringBuilder message = new StringBuilder();
|
||||
for (String exclude : invalidExcludes) {
|
||||
message.append("\t- ").append(exclude).append(String.format("%n"));
|
||||
}
|
||||
throw new IllegalStateException(String
|
||||
.format("The following classes could not be excluded because they are"
|
||||
+ " not auto-configuration classes:%n%s", message));
|
||||
}
|
||||
|
||||
/**
|
||||
* Return any exclusions that limit the candidate configurations.
|
||||
* @param metadata the source metadata
|
||||
* @param attributes the {@link #getAttributes(AnnotationMetadata) annotation
|
||||
* attributes}
|
||||
* @return exclusions or an empty set
|
||||
*/
|
||||
protected Set<String> getExclusions(AnnotationMetadata metadata,
|
||||
AnnotationAttributes attributes) {
|
||||
Set<String> excluded = new LinkedHashSet<String>();
|
||||
excluded.addAll(asList(attributes, "exclude"));
|
||||
excluded.addAll(Arrays.asList(attributes.getStringArray("excludeName")));
|
||||
excluded.addAll(getExcludeAutoConfigurationsProperty());
|
||||
return excluded;
|
||||
}
|
||||
|
||||
private List<String> getExcludeAutoConfigurationsProperty() {
|
||||
if (getEnvironment() instanceof ConfigurableEnvironment) {
|
||||
Excludes excludes = new Excludes();
|
||||
RelaxedDataBinder binder = new RelaxedDataBinder(excludes,
|
||||
"spring.autoconfigure.");
|
||||
binder.bind(new PropertySourcesPropertyValues(
|
||||
((ConfigurableEnvironment) getEnvironment()).getPropertySources()));
|
||||
return excludes.getExclude();
|
||||
}
|
||||
RelaxedPropertyResolver resolver = new RelaxedPropertyResolver(getEnvironment(),
|
||||
"spring.autoconfigure.");
|
||||
String[] exclude = resolver.getProperty("exclude", String[].class);
|
||||
return (Arrays.asList(exclude == null ? new String[0] : exclude));
|
||||
}
|
||||
|
||||
private List<String> sort(List<String> configurations) throws IOException {
|
||||
configurations = new AutoConfigurationSorter(getMetadataReaderFactory())
|
||||
.getInPriorityOrder(configurations);
|
||||
return configurations;
|
||||
}
|
||||
|
||||
private MetadataReaderFactory getMetadataReaderFactory() {
|
||||
try {
|
||||
return getBeanFactory().getBean(
|
||||
SharedMetadataReaderFactoryContextInitializer.BEAN_NAME,
|
||||
MetadataReaderFactory.class);
|
||||
}
|
||||
catch (NoSuchBeanDefinitionException ex) {
|
||||
return new CachingMetadataReaderFactory(this.resourceLoader);
|
||||
}
|
||||
}
|
||||
|
||||
private void recordWithConditionEvaluationReport(List<String> configurations,
|
||||
Collection<String> exclusions) throws IOException {
|
||||
ConditionEvaluationReport report = ConditionEvaluationReport
|
||||
.get(getBeanFactory());
|
||||
report.recordEvaluationCandidates(configurations);
|
||||
report.recordExclusions(exclusions);
|
||||
}
|
||||
|
||||
protected final <T> List<T> removeDuplicates(List<T> list) {
|
||||
return new ArrayList<T>(new LinkedHashSet<T>(list));
|
||||
}
|
||||
|
||||
protected final List<String> asList(AnnotationAttributes attributes, String name) {
|
||||
String[] value = attributes.getStringArray(name);
|
||||
return Arrays.asList(value == null ? new String[0] : value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBeanFactory(BeanFactory beanFactory) throws BeansException {
|
||||
Assert.isInstanceOf(ConfigurableListableBeanFactory.class, beanFactory);
|
||||
this.beanFactory = (ConfigurableListableBeanFactory) beanFactory;
|
||||
}
|
||||
|
||||
protected final ConfigurableListableBeanFactory getBeanFactory() {
|
||||
return this.beanFactory;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBeanClassLoader(ClassLoader classLoader) {
|
||||
this.beanClassLoader = classLoader;
|
||||
}
|
||||
|
||||
protected ClassLoader getBeanClassLoader() {
|
||||
return this.beanClassLoader;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setEnvironment(Environment environment) {
|
||||
this.environment = environment;
|
||||
}
|
||||
|
||||
protected final Environment getEnvironment() {
|
||||
return this.environment;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setResourceLoader(ResourceLoader resourceLoader) {
|
||||
this.resourceLoader = resourceLoader;
|
||||
}
|
||||
|
||||
protected final ResourceLoader getResourceLoader() {
|
||||
return this.resourceLoader;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getOrder() {
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2012-2016 the original author or authors.
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -44,8 +44,7 @@ import org.springframework.util.ObjectUtils;
|
|||
* @author Phillip Webb
|
||||
* @author Andy Wilkinson
|
||||
*/
|
||||
class ImportAutoConfigurationImportSelector
|
||||
extends EnableAutoConfigurationImportSelector {
|
||||
class ImportAutoConfigurationImportSelector extends AutoConfigurationImportSelector {
|
||||
|
||||
private static final Set<String> ANNOTATION_NAMES;
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2012-2016 the original author or authors.
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -16,28 +16,12 @@
|
|||
|
||||
package org.springframework.boot.autoconfigure;
|
||||
|
||||
import java.nio.charset.Charset;
|
||||
|
||||
import org.springframework.boot.autoconfigure.MessageSourceAutoConfiguration.ResourceBundleCondition;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionMessage;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionOutcome;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
||||
import org.springframework.boot.autoconfigure.condition.SearchStrategy;
|
||||
import org.springframework.boot.autoconfigure.condition.SpringBootCondition;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||
import org.springframework.context.MessageSource;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.ConditionContext;
|
||||
import org.springframework.context.annotation.Conditional;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.support.ResourceBundleMessageSource;
|
||||
import org.springframework.context.annotation.Import;
|
||||
import org.springframework.context.annotation.ImportSelector;
|
||||
import org.springframework.core.Ordered;
|
||||
import org.springframework.core.io.Resource;
|
||||
import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
|
||||
import org.springframework.core.type.AnnotatedTypeMetadata;
|
||||
import org.springframework.util.ConcurrentReferenceHashMap;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.springframework.core.type.AnnotationMetadata;
|
||||
|
||||
/**
|
||||
* {@link EnableAutoConfiguration Auto-configuration} for {@link MessageSource}.
|
||||
|
@ -45,146 +29,24 @@ import org.springframework.util.StringUtils;
|
|||
* @author Dave Syer
|
||||
* @author Phillip Webb
|
||||
* @author Eddú Meléndez
|
||||
* @deprecated as of 1.5 in favor of
|
||||
* {@link org.springframework.boot.autoconfigure.context.MessageSourceAutoConfiguration}
|
||||
*/
|
||||
@Configuration
|
||||
@ConditionalOnMissingBean(value = MessageSource.class, search = SearchStrategy.CURRENT)
|
||||
@AutoConfigureOrder(Ordered.HIGHEST_PRECEDENCE)
|
||||
@Conditional(ResourceBundleCondition.class)
|
||||
@EnableConfigurationProperties
|
||||
@ConfigurationProperties(prefix = "spring.messages")
|
||||
@Deprecated
|
||||
@Import(MessageSourceAutoConfiguration.Selector.class)
|
||||
public class MessageSourceAutoConfiguration {
|
||||
|
||||
private static final Resource[] NO_RESOURCES = {};
|
||||
private static final String[] REPLACEMENT = {
|
||||
"org.springframework.boot.autoconfigure.context."
|
||||
+ "MessageSourceAutoConfiguration" };
|
||||
|
||||
/**
|
||||
* Comma-separated list of basenames, each following the ResourceBundle convention.
|
||||
* Essentially a fully-qualified classpath location. If it doesn't contain a package
|
||||
* qualifier (such as "org.mypackage"), it will be resolved from the classpath root.
|
||||
*/
|
||||
private String basename = "messages";
|
||||
|
||||
/**
|
||||
* Message bundles encoding.
|
||||
*/
|
||||
private Charset encoding = Charset.forName("UTF-8");
|
||||
|
||||
/**
|
||||
* Loaded resource bundle files cache expiration, in seconds. When set to -1, bundles
|
||||
* are cached forever.
|
||||
*/
|
||||
private int cacheSeconds = -1;
|
||||
|
||||
/**
|
||||
* Set whether to fall back to the system Locale if no files for a specific Locale
|
||||
* have been found. if this is turned off, the only fallback will be the default file
|
||||
* (e.g. "messages.properties" for basename "messages").
|
||||
*/
|
||||
private boolean fallbackToSystemLocale = true;
|
||||
|
||||
/**
|
||||
* Set whether to always apply the MessageFormat rules, parsing even messages without
|
||||
* arguments.
|
||||
*/
|
||||
private boolean alwaysUseMessageFormat = false;
|
||||
|
||||
@Bean
|
||||
public MessageSource messageSource() {
|
||||
ResourceBundleMessageSource messageSource = new ResourceBundleMessageSource();
|
||||
if (StringUtils.hasText(this.basename)) {
|
||||
messageSource.setBasenames(StringUtils.commaDelimitedListToStringArray(
|
||||
StringUtils.trimAllWhitespace(this.basename)));
|
||||
}
|
||||
if (this.encoding != null) {
|
||||
messageSource.setDefaultEncoding(this.encoding.name());
|
||||
}
|
||||
messageSource.setFallbackToSystemLocale(this.fallbackToSystemLocale);
|
||||
messageSource.setCacheSeconds(this.cacheSeconds);
|
||||
messageSource.setAlwaysUseMessageFormat(this.alwaysUseMessageFormat);
|
||||
return messageSource;
|
||||
}
|
||||
|
||||
public String getBasename() {
|
||||
return this.basename;
|
||||
}
|
||||
|
||||
public void setBasename(String basename) {
|
||||
this.basename = basename;
|
||||
}
|
||||
|
||||
public Charset getEncoding() {
|
||||
return this.encoding;
|
||||
}
|
||||
|
||||
public void setEncoding(Charset encoding) {
|
||||
this.encoding = encoding;
|
||||
}
|
||||
|
||||
public int getCacheSeconds() {
|
||||
return this.cacheSeconds;
|
||||
}
|
||||
|
||||
public void setCacheSeconds(int cacheSeconds) {
|
||||
this.cacheSeconds = cacheSeconds;
|
||||
}
|
||||
|
||||
public boolean isFallbackToSystemLocale() {
|
||||
return this.fallbackToSystemLocale;
|
||||
}
|
||||
|
||||
public void setFallbackToSystemLocale(boolean fallbackToSystemLocale) {
|
||||
this.fallbackToSystemLocale = fallbackToSystemLocale;
|
||||
}
|
||||
|
||||
public boolean isAlwaysUseMessageFormat() {
|
||||
return this.alwaysUseMessageFormat;
|
||||
}
|
||||
|
||||
public void setAlwaysUseMessageFormat(boolean alwaysUseMessageFormat) {
|
||||
this.alwaysUseMessageFormat = alwaysUseMessageFormat;
|
||||
}
|
||||
|
||||
protected static class ResourceBundleCondition extends SpringBootCondition {
|
||||
|
||||
private static ConcurrentReferenceHashMap<String, ConditionOutcome> cache = new ConcurrentReferenceHashMap<String, ConditionOutcome>();
|
||||
static class Selector implements ImportSelector {
|
||||
|
||||
@Override
|
||||
public ConditionOutcome getMatchOutcome(ConditionContext context,
|
||||
AnnotatedTypeMetadata metadata) {
|
||||
String basename = context.getEnvironment()
|
||||
.getProperty("spring.messages.basename", "messages");
|
||||
ConditionOutcome outcome = cache.get(basename);
|
||||
if (outcome == null) {
|
||||
outcome = getMatchOutcomeForBasename(context, basename);
|
||||
cache.put(basename, outcome);
|
||||
}
|
||||
return outcome;
|
||||
}
|
||||
|
||||
private ConditionOutcome getMatchOutcomeForBasename(ConditionContext context,
|
||||
String basename) {
|
||||
ConditionMessage.Builder message = ConditionMessage
|
||||
.forCondition("ResourceBundle");
|
||||
for (String name : StringUtils.commaDelimitedListToStringArray(
|
||||
StringUtils.trimAllWhitespace(basename))) {
|
||||
for (Resource resource : getResources(context.getClassLoader(), name)) {
|
||||
if (resource.exists()) {
|
||||
return ConditionOutcome
|
||||
.match(message.found("bundle").items(resource));
|
||||
}
|
||||
}
|
||||
}
|
||||
return ConditionOutcome.noMatch(
|
||||
message.didNotFind("bundle with basename " + basename).atAll());
|
||||
}
|
||||
|
||||
private Resource[] getResources(ClassLoader classLoader, String name) {
|
||||
try {
|
||||
return new PathMatchingResourcePatternResolver(classLoader)
|
||||
.getResources("classpath*:" + name + ".properties");
|
||||
}
|
||||
catch (Exception ex) {
|
||||
return NO_RESOURCES;
|
||||
}
|
||||
public String[] selectImports(AnnotationMetadata importingClassMetadata) {
|
||||
return REPLACEMENT;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2012-2015 the original author or authors.
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -16,12 +16,12 @@
|
|||
|
||||
package org.springframework.boot.autoconfigure;
|
||||
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
||||
import org.springframework.boot.autoconfigure.condition.SearchStrategy;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.Import;
|
||||
import org.springframework.context.annotation.ImportSelector;
|
||||
import org.springframework.context.support.PropertySourcesPlaceholderConfigurer;
|
||||
import org.springframework.core.Ordered;
|
||||
import org.springframework.core.type.AnnotationMetadata;
|
||||
|
||||
/**
|
||||
* {@link EnableAutoConfiguration Auto-configuration} for
|
||||
|
@ -29,15 +29,26 @@ import org.springframework.core.Ordered;
|
|||
*
|
||||
* @author Phillip Webb
|
||||
* @author Dave Syer
|
||||
* @deprecated as of 1.5 in favor of
|
||||
* {@link org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration}
|
||||
*/
|
||||
@Configuration
|
||||
@AutoConfigureOrder(Ordered.HIGHEST_PRECEDENCE)
|
||||
@Deprecated
|
||||
@Import(PropertyPlaceholderAutoConfiguration.Selector.class)
|
||||
public class PropertyPlaceholderAutoConfiguration {
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean(search = SearchStrategy.CURRENT)
|
||||
public static PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer() {
|
||||
return new PropertySourcesPlaceholderConfigurer();
|
||||
private static final String[] REPLACEMENT = {
|
||||
"org.springframework.boot.autoconfigure.context."
|
||||
+ "PropertyPlaceholderAutoConfiguration" };
|
||||
|
||||
static class Selector implements ImportSelector {
|
||||
|
||||
@Override
|
||||
public String[] selectImports(AnnotationMetadata importingClassMetadata) {
|
||||
return REPLACEMENT;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,53 @@
|
|||
/*
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.boot.autoconfigure.condition;
|
||||
|
||||
import org.springframework.beans.BeansException;
|
||||
import org.springframework.beans.factory.BeanFactory;
|
||||
import org.springframework.beans.factory.BeanFactoryAware;
|
||||
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
|
||||
import org.springframework.boot.autoconfigure.AutoConfigurationImportEvent;
|
||||
import org.springframework.boot.autoconfigure.AutoConfigurationImportListener;
|
||||
|
||||
/**
|
||||
* {@link AutoConfigurationImportListener} to record results with the
|
||||
* {@link ConditionEvaluationReport}.
|
||||
*
|
||||
* @author Phillip Webb
|
||||
*/
|
||||
class ConditionEvaluationReportAutoConfigurationImportListener
|
||||
implements AutoConfigurationImportListener, BeanFactoryAware {
|
||||
|
||||
private ConfigurableListableBeanFactory beanFactory;
|
||||
|
||||
@Override
|
||||
public void onAutoConfigurationImportEvent(AutoConfigurationImportEvent event) {
|
||||
if (this.beanFactory != null) {
|
||||
ConditionEvaluationReport report = ConditionEvaluationReport
|
||||
.get(this.beanFactory);
|
||||
report.recordEvaluationCandidates(event.getCandidateConfigurations());
|
||||
report.recordExclusions(event.getExclusions());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBeanFactory(BeanFactory beanFactory) throws BeansException {
|
||||
this.beanFactory = (beanFactory instanceof ConfigurableListableBeanFactory
|
||||
? (ConfigurableListableBeanFactory) beanFactory : null);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2012-2016 the original author or authors.
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -17,7 +17,6 @@
|
|||
package org.springframework.boot.autoconfigure.condition;
|
||||
|
||||
import java.lang.annotation.Annotation;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
|
@ -43,8 +42,6 @@ import org.springframework.core.type.MethodMetadata;
|
|||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.ClassUtils;
|
||||
import org.springframework.util.MultiValueMap;
|
||||
import org.springframework.util.ReflectionUtils;
|
||||
import org.springframework.util.ReflectionUtils.MethodCallback;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
|
@ -347,33 +344,23 @@ class OnBeanCondition extends SpringBootCondition implements ConfigurationCondit
|
|||
AnnotatedTypeMetadata metadata, final List<String> beanTypes) {
|
||||
if (metadata instanceof MethodMetadata
|
||||
&& metadata.isAnnotated(Bean.class.getName())) {
|
||||
addDeducedBeanTypeForBeanMethod(context, metadata, beanTypes,
|
||||
(MethodMetadata) metadata);
|
||||
addDeducedBeanTypeForBeanMethod(context, (MethodMetadata) metadata,
|
||||
beanTypes);
|
||||
}
|
||||
}
|
||||
|
||||
private void addDeducedBeanTypeForBeanMethod(ConditionContext context,
|
||||
AnnotatedTypeMetadata metadata, final List<String> beanTypes,
|
||||
final MethodMetadata methodMetadata) {
|
||||
MethodMetadata metadata, final List<String> beanTypes) {
|
||||
try {
|
||||
// We should be safe to load at this point since we are in the
|
||||
// REGISTER_BEAN phase
|
||||
Class<?> configClass = ClassUtils.forName(
|
||||
methodMetadata.getDeclaringClassName(), context.getClassLoader());
|
||||
ReflectionUtils.doWithMethods(configClass, new MethodCallback() {
|
||||
@Override
|
||||
public void doWith(Method method)
|
||||
throws IllegalArgumentException, IllegalAccessException {
|
||||
if (methodMetadata.getMethodName().equals(method.getName())) {
|
||||
beanTypes.add(method.getReturnType().getName());
|
||||
}
|
||||
}
|
||||
});
|
||||
Class<?> returnType = ClassUtils.forName(metadata.getReturnTypeName(),
|
||||
context.getClassLoader());
|
||||
beanTypes.add(returnType.getName());
|
||||
}
|
||||
catch (Throwable ex) {
|
||||
throw new BeanTypeDeductionException(
|
||||
methodMetadata.getDeclaringClassName(),
|
||||
methodMetadata.getMethodName(), ex);
|
||||
throw new BeanTypeDeductionException(metadata.getDeclaringClassName(),
|
||||
metadata.getMethodName(), ex);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2012-2016 the original author or authors.
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -16,11 +16,20 @@
|
|||
|
||||
package org.springframework.boot.autoconfigure.condition;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.springframework.beans.BeansException;
|
||||
import org.springframework.beans.factory.BeanClassLoaderAware;
|
||||
import org.springframework.beans.factory.BeanFactory;
|
||||
import org.springframework.beans.factory.BeanFactoryAware;
|
||||
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
|
||||
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
|
||||
import org.springframework.boot.autoconfigure.AutoConfigurationImportFilter;
|
||||
import org.springframework.boot.autoconfigure.AutoConfigurationMetadata;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionMessage.Style;
|
||||
import org.springframework.context.annotation.Condition;
|
||||
import org.springframework.context.annotation.ConditionContext;
|
||||
|
@ -31,24 +40,113 @@ import org.springframework.util.ClassUtils;
|
|||
import org.springframework.util.MultiValueMap;
|
||||
|
||||
/**
|
||||
* {@link Condition} that checks for the presence or absence of specific classes.
|
||||
* {@link Condition} and {@link AutoConfigurationImportFilter} that checks for the
|
||||
* presence or absence of specific classes.
|
||||
*
|
||||
* @author Phillip Webb
|
||||
* @see ConditionalOnClass
|
||||
* @see ConditionalOnMissingClass
|
||||
*/
|
||||
@Order(Ordered.HIGHEST_PRECEDENCE)
|
||||
class OnClassCondition extends SpringBootCondition {
|
||||
class OnClassCondition extends SpringBootCondition
|
||||
implements AutoConfigurationImportFilter, BeanFactoryAware, BeanClassLoaderAware {
|
||||
|
||||
private BeanFactory beanFactory;
|
||||
|
||||
private ClassLoader beanClassLoader;
|
||||
|
||||
@Override
|
||||
public boolean[] match(String[] autoConfigurationClasses,
|
||||
AutoConfigurationMetadata autoConfigurationMetadata) {
|
||||
ConditionEvaluationReport report = getConditionEvaluationReport();
|
||||
ConditionOutcome[] outcomes = getOutcomes(autoConfigurationClasses,
|
||||
autoConfigurationMetadata);
|
||||
boolean[] match = new boolean[outcomes.length];
|
||||
for (int i = 0; i < outcomes.length; i++) {
|
||||
match[i] = (outcomes[i] == null || outcomes[i].isMatch());
|
||||
if (!match[i] && outcomes[i] != null) {
|
||||
logOutcome(autoConfigurationClasses[i], outcomes[i]);
|
||||
if (report != null) {
|
||||
report.recordConditionEvaluation(autoConfigurationClasses[i], this,
|
||||
outcomes[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
return match;
|
||||
}
|
||||
|
||||
private ConditionEvaluationReport getConditionEvaluationReport() {
|
||||
if (this.beanFactory != null
|
||||
&& this.beanFactory instanceof ConfigurableBeanFactory) {
|
||||
return ConditionEvaluationReport
|
||||
.get((ConfigurableListableBeanFactory) this.beanFactory);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private ConditionOutcome[] getOutcomes(String[] autoConfigurationClasses,
|
||||
AutoConfigurationMetadata autoConfigurationMetadata) {
|
||||
// Split the work and perform half in a background thread. Using a single
|
||||
// additional thread seems to offer the best performance. More threads make
|
||||
// things worse
|
||||
int split = autoConfigurationClasses.length / 2;
|
||||
GetOutcomesThread thread = new GetOutcomesThread(autoConfigurationClasses, 0,
|
||||
split, autoConfigurationMetadata);
|
||||
thread.start();
|
||||
ConditionOutcome[] secondHalf = getOutcomes(autoConfigurationClasses, split,
|
||||
autoConfigurationClasses.length, autoConfigurationMetadata);
|
||||
try {
|
||||
thread.join();
|
||||
}
|
||||
catch (InterruptedException ex) {
|
||||
Thread.currentThread().interrupt();
|
||||
}
|
||||
ConditionOutcome[] firstHalf = thread.getResult();
|
||||
ConditionOutcome[] outcomes = new ConditionOutcome[autoConfigurationClasses.length];
|
||||
System.arraycopy(firstHalf, 0, outcomes, 0, firstHalf.length);
|
||||
System.arraycopy(secondHalf, 0, outcomes, split, secondHalf.length);
|
||||
return outcomes;
|
||||
}
|
||||
|
||||
private ConditionOutcome[] getOutcomes(final String[] autoConfigurationClasses,
|
||||
int start, int end, AutoConfigurationMetadata autoConfigurationMetadata) {
|
||||
ConditionOutcome[] outcomes = new ConditionOutcome[end - start];
|
||||
for (int i = start; i < end; i++) {
|
||||
String autoConfigurationClass = autoConfigurationClasses[i];
|
||||
Set<String> candidates = autoConfigurationMetadata
|
||||
.getSet(autoConfigurationClass, "ConditionalOnClass");
|
||||
if (candidates != null) {
|
||||
outcomes[i - start] = getOutcome(candidates);
|
||||
}
|
||||
}
|
||||
return outcomes;
|
||||
}
|
||||
|
||||
private ConditionOutcome getOutcome(Set<String> candidates) {
|
||||
try {
|
||||
List<String> missing = getMatches(candidates, MatchType.MISSING,
|
||||
this.beanClassLoader);
|
||||
if (!missing.isEmpty()) {
|
||||
return ConditionOutcome
|
||||
.noMatch(ConditionMessage.forCondition(ConditionalOnClass.class)
|
||||
.didNotFind("required class", "required classes")
|
||||
.items(Style.QUOTE, missing));
|
||||
}
|
||||
}
|
||||
catch (Exception ex) {
|
||||
// We'll get another chance later
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ConditionOutcome getMatchOutcome(ConditionContext context,
|
||||
AnnotatedTypeMetadata metadata) {
|
||||
ClassLoader classLoader = context.getClassLoader();
|
||||
ConditionMessage matchMessage = ConditionMessage.empty();
|
||||
MultiValueMap<String, Object> onClasses = getAttributes(metadata,
|
||||
ConditionalOnClass.class);
|
||||
List<String> onClasses = getCandidates(metadata, ConditionalOnClass.class);
|
||||
if (onClasses != null) {
|
||||
List<String> missing = getMatchingClasses(onClasses, MatchType.MISSING,
|
||||
context);
|
||||
List<String> missing = getMatches(onClasses, MatchType.MISSING, classLoader);
|
||||
if (!missing.isEmpty()) {
|
||||
return ConditionOutcome
|
||||
.noMatch(ConditionMessage.forCondition(ConditionalOnClass.class)
|
||||
|
@ -57,13 +155,13 @@ class OnClassCondition extends SpringBootCondition {
|
|||
}
|
||||
matchMessage = matchMessage.andCondition(ConditionalOnClass.class)
|
||||
.found("required class", "required classes").items(Style.QUOTE,
|
||||
getMatchingClasses(onClasses, MatchType.PRESENT, context));
|
||||
getMatches(onClasses, MatchType.PRESENT, classLoader));
|
||||
}
|
||||
MultiValueMap<String, Object> onMissingClasses = getAttributes(metadata,
|
||||
List<String> onMissingClasses = getCandidates(metadata,
|
||||
ConditionalOnMissingClass.class);
|
||||
if (onMissingClasses != null) {
|
||||
List<String> present = getMatchingClasses(onMissingClasses, MatchType.PRESENT,
|
||||
context);
|
||||
List<String> present = getMatches(onMissingClasses, MatchType.PRESENT,
|
||||
classLoader);
|
||||
if (!present.isEmpty()) {
|
||||
return ConditionOutcome.noMatch(
|
||||
ConditionMessage.forCondition(ConditionalOnMissingClass.class)
|
||||
|
@ -71,30 +169,23 @@ class OnClassCondition extends SpringBootCondition {
|
|||
.items(Style.QUOTE, present));
|
||||
}
|
||||
matchMessage = matchMessage.andCondition(ConditionalOnMissingClass.class)
|
||||
.didNotFind("unwanted class", "unwanted classes")
|
||||
.items(Style.QUOTE, getMatchingClasses(onMissingClasses,
|
||||
MatchType.MISSING, context));
|
||||
.didNotFind("unwanted class", "unwanted classes").items(Style.QUOTE,
|
||||
getMatches(onMissingClasses, MatchType.MISSING, classLoader));
|
||||
}
|
||||
return ConditionOutcome.match(matchMessage);
|
||||
}
|
||||
|
||||
private MultiValueMap<String, Object> getAttributes(AnnotatedTypeMetadata metadata,
|
||||
private List<String> getCandidates(AnnotatedTypeMetadata metadata,
|
||||
Class<?> annotationType) {
|
||||
return metadata.getAllAnnotationAttributes(annotationType.getName(), true);
|
||||
}
|
||||
|
||||
private List<String> getMatchingClasses(MultiValueMap<String, Object> attributes,
|
||||
MatchType matchType, ConditionContext context) {
|
||||
List<String> matches = new LinkedList<String>();
|
||||
addAll(matches, attributes.get("value"));
|
||||
addAll(matches, attributes.get("name"));
|
||||
Iterator<String> iterator = matches.iterator();
|
||||
while (iterator.hasNext()) {
|
||||
if (!matchType.matches(iterator.next(), context)) {
|
||||
iterator.remove();
|
||||
}
|
||||
MultiValueMap<String, Object> attributes = metadata
|
||||
.getAllAnnotationAttributes(annotationType.getName(), true);
|
||||
List<String> candidates = new ArrayList<String>();
|
||||
if (attributes == null) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
return matches;
|
||||
addAll(candidates, attributes.get("value"));
|
||||
addAll(candidates, attributes.get("name"));
|
||||
return candidates;
|
||||
}
|
||||
|
||||
private void addAll(List<String> list, List<Object> itemsToAdd) {
|
||||
|
@ -105,13 +196,34 @@ class OnClassCondition extends SpringBootCondition {
|
|||
}
|
||||
}
|
||||
|
||||
private List<String> getMatches(Collection<String> candiates, MatchType matchType,
|
||||
ClassLoader classLoader) {
|
||||
List<String> matches = new ArrayList<String>(candiates.size());
|
||||
for (String candidate : candiates) {
|
||||
if (matchType.matches(candidate, classLoader)) {
|
||||
matches.add(candidate);
|
||||
}
|
||||
}
|
||||
return matches;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBeanFactory(BeanFactory beanFactory) throws BeansException {
|
||||
this.beanFactory = beanFactory;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBeanClassLoader(ClassLoader classLoader) {
|
||||
this.beanClassLoader = classLoader;
|
||||
}
|
||||
|
||||
private enum MatchType {
|
||||
|
||||
PRESENT {
|
||||
|
||||
@Override
|
||||
public boolean matches(String className, ConditionContext context) {
|
||||
return ClassUtils.isPresent(className, context.getClassLoader());
|
||||
public boolean matches(String className, ClassLoader classLoader) {
|
||||
return isPresent(className, classLoader);
|
||||
}
|
||||
|
||||
},
|
||||
|
@ -119,14 +231,66 @@ class OnClassCondition extends SpringBootCondition {
|
|||
MISSING {
|
||||
|
||||
@Override
|
||||
public boolean matches(String className, ConditionContext context) {
|
||||
return !ClassUtils.isPresent(className, context.getClassLoader());
|
||||
public boolean matches(String className, ClassLoader classLoader) {
|
||||
return !isPresent(className, classLoader);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
public abstract boolean matches(String className, ConditionContext context);
|
||||
private static boolean isPresent(String className, ClassLoader classLoader) {
|
||||
if (classLoader == null) {
|
||||
classLoader = ClassUtils.getDefaultClassLoader();
|
||||
}
|
||||
try {
|
||||
forName(className, classLoader);
|
||||
return true;
|
||||
}
|
||||
catch (Throwable ex) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private static Class<?> forName(String className, ClassLoader classLoader)
|
||||
throws ClassNotFoundException {
|
||||
if (classLoader != null) {
|
||||
return classLoader.loadClass(className);
|
||||
}
|
||||
return Class.forName(className);
|
||||
}
|
||||
|
||||
public abstract boolean matches(String className, ClassLoader classLoader);
|
||||
|
||||
}
|
||||
|
||||
private class GetOutcomesThread extends Thread {
|
||||
|
||||
private final String[] autoConfigurationClasses;
|
||||
|
||||
private final int start;
|
||||
|
||||
private final int end;
|
||||
|
||||
private final AutoConfigurationMetadata autoConfigurationMetadata;
|
||||
|
||||
private ConditionOutcome[] outcomes;
|
||||
|
||||
GetOutcomesThread(String[] autoConfigurationClasses, int start, int end,
|
||||
AutoConfigurationMetadata autoConfigurationMetadata) {
|
||||
this.autoConfigurationClasses = autoConfigurationClasses;
|
||||
this.start = start;
|
||||
this.end = end;
|
||||
this.autoConfigurationMetadata = autoConfigurationMetadata;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
this.outcomes = getOutcomes(this.autoConfigurationClasses, this.start,
|
||||
this.end, this.autoConfigurationMetadata);
|
||||
}
|
||||
|
||||
public ConditionOutcome[] getResult() {
|
||||
return this.outcomes;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2012-2015 the original author or authors.
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -87,7 +87,7 @@ public abstract class SpringBootCondition implements Condition {
|
|||
+ methodMetadata.getMethodName();
|
||||
}
|
||||
|
||||
private void logOutcome(String classOrMethodName, ConditionOutcome outcome) {
|
||||
protected final void logOutcome(String classOrMethodName, ConditionOutcome outcome) {
|
||||
if (this.logger.isTraceEnabled()) {
|
||||
this.logger.trace(getLogMessage(classOrMethodName, outcome));
|
||||
}
|
||||
|
|
|
@ -0,0 +1,194 @@
|
|||
/*
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.boot.autoconfigure.context;
|
||||
|
||||
import java.nio.charset.Charset;
|
||||
|
||||
import org.springframework.boot.autoconfigure.AutoConfigureOrder;
|
||||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionMessage;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionOutcome;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
||||
import org.springframework.boot.autoconfigure.condition.SearchStrategy;
|
||||
import org.springframework.boot.autoconfigure.condition.SpringBootCondition;
|
||||
import org.springframework.boot.autoconfigure.context.MessageSourceAutoConfiguration.ResourceBundleCondition;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||
import org.springframework.context.MessageSource;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.ConditionContext;
|
||||
import org.springframework.context.annotation.Conditional;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.support.ResourceBundleMessageSource;
|
||||
import org.springframework.core.Ordered;
|
||||
import org.springframework.core.io.Resource;
|
||||
import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
|
||||
import org.springframework.core.type.AnnotatedTypeMetadata;
|
||||
import org.springframework.util.ConcurrentReferenceHashMap;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
* {@link EnableAutoConfiguration Auto-configuration} for {@link MessageSource}.
|
||||
*
|
||||
* @author Dave Syer
|
||||
* @author Phillip Webb
|
||||
* @author Eddú Meléndez
|
||||
*/
|
||||
@Configuration
|
||||
@ConditionalOnMissingBean(value = MessageSource.class, search = SearchStrategy.CURRENT)
|
||||
@AutoConfigureOrder(Ordered.HIGHEST_PRECEDENCE)
|
||||
@Conditional(ResourceBundleCondition.class)
|
||||
@EnableConfigurationProperties
|
||||
@ConfigurationProperties(prefix = "spring.messages")
|
||||
public class MessageSourceAutoConfiguration {
|
||||
|
||||
private static final Resource[] NO_RESOURCES = {};
|
||||
|
||||
/**
|
||||
* Comma-separated list of basenames, each following the ResourceBundle convention.
|
||||
* Essentially a fully-qualified classpath location. If it doesn't contain a package
|
||||
* qualifier (such as "org.mypackage"), it will be resolved from the classpath root.
|
||||
*/
|
||||
private String basename = "messages";
|
||||
|
||||
/**
|
||||
* Message bundles encoding.
|
||||
*/
|
||||
private Charset encoding = Charset.forName("UTF-8");
|
||||
|
||||
/**
|
||||
* Loaded resource bundle files cache expiration, in seconds. When set to -1, bundles
|
||||
* are cached forever.
|
||||
*/
|
||||
private int cacheSeconds = -1;
|
||||
|
||||
/**
|
||||
* Set whether to fall back to the system Locale if no files for a specific Locale
|
||||
* have been found. if this is turned off, the only fallback will be the default file
|
||||
* (e.g. "messages.properties" for basename "messages").
|
||||
*/
|
||||
private boolean fallbackToSystemLocale = true;
|
||||
|
||||
/**
|
||||
* Set whether to always apply the MessageFormat rules, parsing even messages without
|
||||
* arguments.
|
||||
*/
|
||||
private boolean alwaysUseMessageFormat = false;
|
||||
|
||||
@Bean
|
||||
public MessageSource messageSource() {
|
||||
ResourceBundleMessageSource messageSource = new ResourceBundleMessageSource();
|
||||
if (StringUtils.hasText(this.basename)) {
|
||||
messageSource.setBasenames(StringUtils.commaDelimitedListToStringArray(
|
||||
StringUtils.trimAllWhitespace(this.basename)));
|
||||
}
|
||||
if (this.encoding != null) {
|
||||
messageSource.setDefaultEncoding(this.encoding.name());
|
||||
}
|
||||
messageSource.setFallbackToSystemLocale(this.fallbackToSystemLocale);
|
||||
messageSource.setCacheSeconds(this.cacheSeconds);
|
||||
messageSource.setAlwaysUseMessageFormat(this.alwaysUseMessageFormat);
|
||||
return messageSource;
|
||||
}
|
||||
|
||||
public String getBasename() {
|
||||
return this.basename;
|
||||
}
|
||||
|
||||
public void setBasename(String basename) {
|
||||
this.basename = basename;
|
||||
}
|
||||
|
||||
public Charset getEncoding() {
|
||||
return this.encoding;
|
||||
}
|
||||
|
||||
public void setEncoding(Charset encoding) {
|
||||
this.encoding = encoding;
|
||||
}
|
||||
|
||||
public int getCacheSeconds() {
|
||||
return this.cacheSeconds;
|
||||
}
|
||||
|
||||
public void setCacheSeconds(int cacheSeconds) {
|
||||
this.cacheSeconds = cacheSeconds;
|
||||
}
|
||||
|
||||
public boolean isFallbackToSystemLocale() {
|
||||
return this.fallbackToSystemLocale;
|
||||
}
|
||||
|
||||
public void setFallbackToSystemLocale(boolean fallbackToSystemLocale) {
|
||||
this.fallbackToSystemLocale = fallbackToSystemLocale;
|
||||
}
|
||||
|
||||
public boolean isAlwaysUseMessageFormat() {
|
||||
return this.alwaysUseMessageFormat;
|
||||
}
|
||||
|
||||
public void setAlwaysUseMessageFormat(boolean alwaysUseMessageFormat) {
|
||||
this.alwaysUseMessageFormat = alwaysUseMessageFormat;
|
||||
}
|
||||
|
||||
protected static class ResourceBundleCondition extends SpringBootCondition {
|
||||
|
||||
private static ConcurrentReferenceHashMap<String, ConditionOutcome> cache = new ConcurrentReferenceHashMap<String, ConditionOutcome>();
|
||||
|
||||
@Override
|
||||
public ConditionOutcome getMatchOutcome(ConditionContext context,
|
||||
AnnotatedTypeMetadata metadata) {
|
||||
String basename = context.getEnvironment()
|
||||
.getProperty("spring.messages.basename", "messages");
|
||||
ConditionOutcome outcome = cache.get(basename);
|
||||
if (outcome == null) {
|
||||
outcome = getMatchOutcomeForBasename(context, basename);
|
||||
cache.put(basename, outcome);
|
||||
}
|
||||
return outcome;
|
||||
}
|
||||
|
||||
private ConditionOutcome getMatchOutcomeForBasename(ConditionContext context,
|
||||
String basename) {
|
||||
ConditionMessage.Builder message = ConditionMessage
|
||||
.forCondition("ResourceBundle");
|
||||
for (String name : StringUtils.commaDelimitedListToStringArray(
|
||||
StringUtils.trimAllWhitespace(basename))) {
|
||||
for (Resource resource : getResources(context.getClassLoader(), name)) {
|
||||
if (resource.exists()) {
|
||||
return ConditionOutcome
|
||||
.match(message.found("bundle").items(resource));
|
||||
}
|
||||
}
|
||||
}
|
||||
return ConditionOutcome.noMatch(
|
||||
message.didNotFind("bundle with basename " + basename).atAll());
|
||||
}
|
||||
|
||||
private Resource[] getResources(ClassLoader classLoader, String name) {
|
||||
try {
|
||||
return new PathMatchingResourcePatternResolver(classLoader)
|
||||
.getResources("classpath*:" + name + ".properties");
|
||||
}
|
||||
catch (Exception ex) {
|
||||
return NO_RESOURCES;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,45 @@
|
|||
/*
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.boot.autoconfigure.context;
|
||||
|
||||
import org.springframework.boot.autoconfigure.AutoConfigureOrder;
|
||||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
||||
import org.springframework.boot.autoconfigure.condition.SearchStrategy;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.support.PropertySourcesPlaceholderConfigurer;
|
||||
import org.springframework.core.Ordered;
|
||||
|
||||
/**
|
||||
* {@link EnableAutoConfiguration Auto-configuration} for
|
||||
* {@link PropertySourcesPlaceholderConfigurer}.
|
||||
*
|
||||
* @author Phillip Webb
|
||||
* @author Dave Syer
|
||||
*/
|
||||
@Configuration
|
||||
@AutoConfigureOrder(Ordered.HIGHEST_PRECEDENCE)
|
||||
public class PropertyPlaceholderAutoConfiguration {
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean(search = SearchStrategy.CURRENT)
|
||||
public static PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer() {
|
||||
return new PropertySourcesPlaceholderConfigurer();
|
||||
}
|
||||
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2012-2016 the original author or authors.
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -19,11 +19,11 @@ package org.springframework.boot.autoconfigure.web;
|
|||
import org.springframework.boot.autoconfigure.condition.ConditionMessage;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionOutcome;
|
||||
import org.springframework.boot.autoconfigure.condition.SpringBootCondition;
|
||||
import org.springframework.boot.bind.PropertySourcesPropertyValues;
|
||||
import org.springframework.boot.bind.RelaxedDataBinder;
|
||||
import org.springframework.boot.bind.RelaxedPropertyResolver;
|
||||
import org.springframework.context.annotation.Condition;
|
||||
import org.springframework.context.annotation.ConditionContext;
|
||||
import org.springframework.core.env.ConfigurableEnvironment;
|
||||
import org.springframework.core.env.PropertyResolver;
|
||||
import org.springframework.core.type.AnnotatedTypeMetadata;
|
||||
import org.springframework.util.ClassUtils;
|
||||
|
||||
|
@ -32,6 +32,7 @@ import org.springframework.util.ClassUtils;
|
|||
* enabled.
|
||||
*
|
||||
* @author Stephane Nicoll
|
||||
* @author Phillip Webb
|
||||
* @see ConditionalOnEnabledResourceChain
|
||||
*/
|
||||
class OnEnabledResourceChainCondition extends SpringBootCondition {
|
||||
|
@ -43,10 +44,10 @@ class OnEnabledResourceChainCondition extends SpringBootCondition {
|
|||
AnnotatedTypeMetadata metadata) {
|
||||
ConfigurableEnvironment environment = (ConfigurableEnvironment) context
|
||||
.getEnvironment();
|
||||
ResourceProperties properties = new ResourceProperties();
|
||||
RelaxedDataBinder binder = new RelaxedDataBinder(properties, "spring.resources");
|
||||
binder.bind(new PropertySourcesPropertyValues(environment.getPropertySources()));
|
||||
Boolean match = properties.getChain().getEnabled();
|
||||
boolean fixed = getEnabledProperty(environment, "strategy.fixed.", false);
|
||||
boolean content = getEnabledProperty(environment, "strategy.content.", false);
|
||||
Boolean chain = getEnabledProperty(environment, "", null);
|
||||
Boolean match = ResourceProperties.Chain.getEnabled(fixed, content, chain);
|
||||
ConditionMessage.Builder message = ConditionMessage
|
||||
.forCondition(ConditionalOnEnabledResourceChain.class);
|
||||
if (match == null) {
|
||||
|
@ -63,4 +64,11 @@ class OnEnabledResourceChainCondition extends SpringBootCondition {
|
|||
return ConditionOutcome.noMatch(message.because("disabled"));
|
||||
}
|
||||
|
||||
private Boolean getEnabledProperty(ConfigurableEnvironment environment, String key,
|
||||
Boolean defaultValue) {
|
||||
PropertyResolver resolver = new RelaxedPropertyResolver(environment,
|
||||
"spring.resources.chain." + key);
|
||||
return resolver.getProperty("enabled", Boolean.class, defaultValue);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2012-2016 the original author or authors.
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -186,9 +186,8 @@ public class ResourceProperties implements ResourceLoaderAware {
|
|||
* settings are present.
|
||||
*/
|
||||
public Boolean getEnabled() {
|
||||
Boolean strategyEnabled = getStrategy().getFixed().isEnabled()
|
||||
|| getStrategy().getContent().isEnabled();
|
||||
return (strategyEnabled ? Boolean.TRUE : this.enabled);
|
||||
return getEnabled(getStrategy().getFixed().isEnabled(),
|
||||
getStrategy().getContent().isEnabled(), this.enabled);
|
||||
}
|
||||
|
||||
public void setEnabled(boolean enabled) {
|
||||
|
@ -223,6 +222,11 @@ public class ResourceProperties implements ResourceLoaderAware {
|
|||
this.gzipped = gzipped;
|
||||
}
|
||||
|
||||
static Boolean getEnabled(boolean fixedEnabled, boolean contentEnabled,
|
||||
Boolean chainEnabled) {
|
||||
return (fixedEnabled || contentEnabled ? Boolean.TRUE : chainEnabled);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -7,18 +7,26 @@ org.springframework.boot.autoconfigure.logging.AutoConfigurationReportLoggingIni
|
|||
org.springframework.context.ApplicationListener=\
|
||||
org.springframework.boot.autoconfigure.BackgroundPreinitializer
|
||||
|
||||
# Auto Configuration Import Listeners
|
||||
org.springframework.boot.autoconfigure.AutoConfigurationImportListener=\
|
||||
org.springframework.boot.autoconfigure.condition.ConditionEvaluationReportAutoConfigurationImportListener
|
||||
|
||||
# Auto Configuration Import Filters
|
||||
org.springframework.boot.autoconfigure.AutoConfigurationImportFilter=\
|
||||
org.springframework.boot.autoconfigure.condition.OnClassCondition
|
||||
|
||||
# Auto Configure
|
||||
org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
|
||||
org.springframework.boot.autoconfigure.admin.SpringApplicationAdminJmxAutoConfiguration,\
|
||||
org.springframework.boot.autoconfigure.aop.AopAutoConfiguration,\
|
||||
org.springframework.boot.autoconfigure.amqp.RabbitAutoConfiguration,\
|
||||
org.springframework.boot.autoconfigure.MessageSourceAutoConfiguration,\
|
||||
org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfiguration,\
|
||||
org.springframework.boot.autoconfigure.batch.BatchAutoConfiguration,\
|
||||
org.springframework.boot.autoconfigure.cache.CacheAutoConfiguration,\
|
||||
org.springframework.boot.autoconfigure.cassandra.CassandraAutoConfiguration,\
|
||||
org.springframework.boot.autoconfigure.cloud.CloudAutoConfiguration,\
|
||||
org.springframework.boot.autoconfigure.context.ConfigurationPropertiesAutoConfiguration,\
|
||||
org.springframework.boot.autoconfigure.context.MessageSourceAutoConfiguration,\
|
||||
org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration,\
|
||||
org.springframework.boot.autoconfigure.couchbase.CouchbaseAutoConfiguration,\
|
||||
org.springframework.boot.autoconfigure.dao.PersistenceExceptionTranslationAutoConfiguration,\
|
||||
org.springframework.boot.autoconfigure.data.cassandra.CassandraDataAutoConfiguration,\
|
||||
|
|
|
@ -0,0 +1,345 @@
|
|||
/*
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.boot.autoconfigure;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.rules.ExpectedException;
|
||||
import org.mockito.MockitoAnnotations;
|
||||
|
||||
import org.springframework.beans.BeansException;
|
||||
import org.springframework.beans.factory.BeanFactory;
|
||||
import org.springframework.beans.factory.BeanFactoryAware;
|
||||
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
|
||||
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
|
||||
import org.springframework.boot.autoconfigure.freemarker.FreeMarkerAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.mustache.MustacheAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.thymeleaf.ThymeleafAutoConfiguration;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.core.io.DefaultResourceLoader;
|
||||
import org.springframework.core.io.support.SpringFactoriesLoader;
|
||||
import org.springframework.core.type.StandardAnnotationMetadata;
|
||||
import org.springframework.mock.env.MockEnvironment;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
/**
|
||||
* Tests for {@link AutoConfigurationImportSelector}
|
||||
*
|
||||
* @author Andy Wilkinson
|
||||
* @author Stephane Nicoll
|
||||
* @author Madhura Bhave
|
||||
*/
|
||||
public class AutoConfigurationImportSelectorTests {
|
||||
|
||||
private final TestAutoConfigurationImportSelector importSelector = new TestAutoConfigurationImportSelector();
|
||||
|
||||
private final ConfigurableListableBeanFactory beanFactory = new DefaultListableBeanFactory();
|
||||
|
||||
private final MockEnvironment environment = new MockEnvironment();
|
||||
|
||||
private List<AutoConfigurationImportFilter> filters = new ArrayList<AutoConfigurationImportFilter>();
|
||||
|
||||
@Rule
|
||||
public ExpectedException expected = ExpectedException.none();
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
MockitoAnnotations.initMocks(this);
|
||||
this.importSelector.setBeanFactory(this.beanFactory);
|
||||
this.importSelector.setEnvironment(this.environment);
|
||||
this.importSelector.setResourceLoader(new DefaultResourceLoader());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void importsAreSelectedWhenUsingEnableAutoConfiguration() {
|
||||
String[] imports = selectImports(BasicEnableAutoConfiguration.class);
|
||||
assertThat(imports).hasSameSizeAs(SpringFactoriesLoader.loadFactoryNames(
|
||||
EnableAutoConfiguration.class, getClass().getClassLoader()));
|
||||
assertThat(this.importSelector.getLastEvent().getExclusions()).isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void classExclusionsAreApplied() {
|
||||
String[] imports = selectImports(
|
||||
EnableAutoConfigurationWithClassExclusions.class);
|
||||
assertThat(imports).hasSize(getAutoConfigurationClassNames().size() - 1);
|
||||
assertThat(this.importSelector.getLastEvent().getExclusions())
|
||||
.contains(FreeMarkerAutoConfiguration.class.getName());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void classExclusionsAreAppliedWhenUsingSpringBootApplication() {
|
||||
String[] imports = selectImports(SpringBootApplicationWithClassExclusions.class);
|
||||
assertThat(imports).hasSize(getAutoConfigurationClassNames().size() - 1);
|
||||
assertThat(this.importSelector.getLastEvent().getExclusions())
|
||||
.contains(FreeMarkerAutoConfiguration.class.getName());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void classNamesExclusionsAreApplied() {
|
||||
String[] imports = selectImports(
|
||||
EnableAutoConfigurationWithClassNameExclusions.class);
|
||||
assertThat(imports).hasSize(getAutoConfigurationClassNames().size() - 1);
|
||||
assertThat(this.importSelector.getLastEvent().getExclusions())
|
||||
.contains(MustacheAutoConfiguration.class.getName());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void classNamesExclusionsAreAppliedWhenUsingSpringBootApplication() {
|
||||
String[] imports = selectImports(
|
||||
SpringBootApplicationWithClassNameExclusions.class);
|
||||
assertThat(imports).hasSize(getAutoConfigurationClassNames().size() - 1);
|
||||
assertThat(this.importSelector.getLastEvent().getExclusions())
|
||||
.contains(MustacheAutoConfiguration.class.getName());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void propertyExclusionsAreApplied() {
|
||||
this.environment.setProperty("spring.autoconfigure.exclude",
|
||||
FreeMarkerAutoConfiguration.class.getName());
|
||||
String[] imports = selectImports(BasicEnableAutoConfiguration.class);
|
||||
assertThat(imports).hasSize(getAutoConfigurationClassNames().size() - 1);
|
||||
assertThat(this.importSelector.getLastEvent().getExclusions())
|
||||
.contains(FreeMarkerAutoConfiguration.class.getName());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void severalPropertyExclusionsAreApplied() {
|
||||
this.environment.setProperty("spring.autoconfigure.exclude",
|
||||
FreeMarkerAutoConfiguration.class.getName() + ","
|
||||
+ MustacheAutoConfiguration.class.getName());
|
||||
String[] imports = selectImports(BasicEnableAutoConfiguration.class);
|
||||
assertThat(imports).hasSize(getAutoConfigurationClassNames().size() - 2);
|
||||
assertThat(this.importSelector.getLastEvent().getExclusions()).contains(
|
||||
FreeMarkerAutoConfiguration.class.getName(),
|
||||
MustacheAutoConfiguration.class.getName());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void severalPropertyYamlExclusionsAreApplied() {
|
||||
this.environment.setProperty("spring.autoconfigure.exclude[0]",
|
||||
FreeMarkerAutoConfiguration.class.getName());
|
||||
this.environment.setProperty("spring.autoconfigure.exclude[1]",
|
||||
MustacheAutoConfiguration.class.getName());
|
||||
String[] imports = selectImports(BasicEnableAutoConfiguration.class);
|
||||
assertThat(imports).hasSize(getAutoConfigurationClassNames().size() - 2);
|
||||
assertThat(this.importSelector.getLastEvent().getExclusions()).contains(
|
||||
FreeMarkerAutoConfiguration.class.getName(),
|
||||
MustacheAutoConfiguration.class.getName());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void combinedExclusionsAreApplied() {
|
||||
this.environment.setProperty("spring.autoconfigure.exclude",
|
||||
ThymeleafAutoConfiguration.class.getName());
|
||||
String[] imports = selectImports(
|
||||
EnableAutoConfigurationWithClassAndClassNameExclusions.class);
|
||||
assertThat(imports).hasSize(getAutoConfigurationClassNames().size() - 3);
|
||||
assertThat(this.importSelector.getLastEvent().getExclusions()).contains(
|
||||
FreeMarkerAutoConfiguration.class.getName(),
|
||||
MustacheAutoConfiguration.class.getName(),
|
||||
ThymeleafAutoConfiguration.class.getName());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void nonAutoConfigurationClassExclusionsShouldThrowException()
|
||||
throws Exception {
|
||||
this.expected.expect(IllegalStateException.class);
|
||||
selectImports(EnableAutoConfigurationWithFaultyClassExclude.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void nonAutoConfigurationClassNameExclusionsWhenPresentOnClassPathShouldThrowException()
|
||||
throws Exception {
|
||||
this.expected.expect(IllegalStateException.class);
|
||||
selectImports(EnableAutoConfigurationWithFaultyClassNameExclude.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void nonAutoConfigurationPropertyExclusionsWhenPresentOnClassPathShouldThrowException()
|
||||
throws Exception {
|
||||
this.environment.setProperty("spring.autoconfigure.exclude",
|
||||
"org.springframework.boot.autoconfigure."
|
||||
+ "AutoConfigurationImportSelectorTests.TestConfiguration");
|
||||
this.expected.expect(IllegalStateException.class);
|
||||
selectImports(BasicEnableAutoConfiguration.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void nameAndPropertyExclusionsWhenNotPresentOnClasspathShouldNotThrowException()
|
||||
throws Exception {
|
||||
this.environment.setProperty("spring.autoconfigure.exclude",
|
||||
"org.springframework.boot.autoconfigure.DoesNotExist2");
|
||||
selectImports(EnableAutoConfigurationWithAbsentClassNameExclude.class);
|
||||
assertThat(this.importSelector.getLastEvent().getExclusions())
|
||||
.containsExactlyInAnyOrder(
|
||||
"org.springframework.boot.autoconfigure.DoesNotExist1",
|
||||
"org.springframework.boot.autoconfigure.DoesNotExist2");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void filterShouldFilterImports() throws Exception {
|
||||
String[] defaultImports = selectImports(BasicEnableAutoConfiguration.class);
|
||||
this.filters.add(new TestAutoConfigurationImportFilter(defaultImports, 1));
|
||||
this.filters.add(new TestAutoConfigurationImportFilter(defaultImports, 3, 4));
|
||||
String[] filtered = selectImports(BasicEnableAutoConfiguration.class);
|
||||
assertThat(filtered).hasSize(defaultImports.length - 3);
|
||||
assertThat(filtered).doesNotContain(defaultImports[1], defaultImports[3],
|
||||
defaultImports[4]);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void filterShouldSupportAware() throws Exception {
|
||||
TestAutoConfigurationImportFilter filter = new TestAutoConfigurationImportFilter(
|
||||
new String[] {});
|
||||
this.filters.add(filter);
|
||||
selectImports(BasicEnableAutoConfiguration.class);
|
||||
assertThat(filter.getBeanFactory()).isEqualTo(this.beanFactory);
|
||||
}
|
||||
|
||||
private String[] selectImports(Class<?> source) {
|
||||
return this.importSelector.selectImports(new StandardAnnotationMetadata(source));
|
||||
}
|
||||
|
||||
private List<String> getAutoConfigurationClassNames() {
|
||||
return SpringFactoriesLoader.loadFactoryNames(EnableAutoConfiguration.class,
|
||||
getClass().getClassLoader());
|
||||
}
|
||||
|
||||
private class TestAutoConfigurationImportSelector
|
||||
extends AutoConfigurationImportSelector {
|
||||
|
||||
private AutoConfigurationImportEvent lastEvent;
|
||||
|
||||
@Override
|
||||
protected List<AutoConfigurationImportFilter> getAutoConfigurationImportFilters() {
|
||||
return AutoConfigurationImportSelectorTests.this.filters;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<AutoConfigurationImportListener> getAutoConfigurationImportListeners() {
|
||||
return Collections.<AutoConfigurationImportListener>singletonList(
|
||||
new AutoConfigurationImportListener() {
|
||||
|
||||
@Override
|
||||
public void onAutoConfigurationImportEvent(
|
||||
AutoConfigurationImportEvent event) {
|
||||
TestAutoConfigurationImportSelector.this.lastEvent = event;
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
public AutoConfigurationImportEvent getLastEvent() {
|
||||
return this.lastEvent;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static class TestAutoConfigurationImportFilter
|
||||
implements AutoConfigurationImportFilter, BeanFactoryAware {
|
||||
|
||||
private final Set<String> nonMatching = new HashSet<String>();
|
||||
|
||||
private BeanFactory beanFactory;
|
||||
|
||||
TestAutoConfigurationImportFilter(String[] configurations, int... nonMatching) {
|
||||
for (int i : nonMatching) {
|
||||
this.nonMatching.add(configurations[i]);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean[] match(String[] autoConfigurationClasses,
|
||||
AutoConfigurationMetadata autoConfigurationMetadata) {
|
||||
boolean[] result = new boolean[autoConfigurationClasses.length];
|
||||
for (int i = 0; i < result.length; i++) {
|
||||
result[i] = !this.nonMatching.contains(autoConfigurationClasses[i]);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBeanFactory(BeanFactory beanFactory) throws BeansException {
|
||||
this.beanFactory = beanFactory;
|
||||
}
|
||||
|
||||
public BeanFactory getBeanFactory() {
|
||||
return this.beanFactory;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Configuration
|
||||
private class TestConfiguration {
|
||||
|
||||
}
|
||||
|
||||
@EnableAutoConfiguration
|
||||
private class BasicEnableAutoConfiguration {
|
||||
|
||||
}
|
||||
|
||||
@EnableAutoConfiguration(exclude = FreeMarkerAutoConfiguration.class)
|
||||
private class EnableAutoConfigurationWithClassExclusions {
|
||||
|
||||
}
|
||||
|
||||
@SpringBootApplication(exclude = FreeMarkerAutoConfiguration.class)
|
||||
private class SpringBootApplicationWithClassExclusions {
|
||||
|
||||
}
|
||||
|
||||
@EnableAutoConfiguration(excludeName = "org.springframework.boot.autoconfigure.mustache.MustacheAutoConfiguration")
|
||||
private class EnableAutoConfigurationWithClassNameExclusions {
|
||||
|
||||
}
|
||||
|
||||
@EnableAutoConfiguration(exclude = MustacheAutoConfiguration.class, excludeName = "org.springframework.boot.autoconfigure.freemarker.FreeMarkerAutoConfiguration")
|
||||
private class EnableAutoConfigurationWithClassAndClassNameExclusions {
|
||||
|
||||
}
|
||||
|
||||
@EnableAutoConfiguration(exclude = TestConfiguration.class)
|
||||
private class EnableAutoConfigurationWithFaultyClassExclude {
|
||||
|
||||
}
|
||||
|
||||
@EnableAutoConfiguration(excludeName = "org.springframework.boot.autoconfigure.AutoConfigurationImportSelectorTests.TestConfiguration")
|
||||
private class EnableAutoConfigurationWithFaultyClassNameExclude {
|
||||
|
||||
}
|
||||
|
||||
@EnableAutoConfiguration(excludeName = "org.springframework.boot.autoconfigure.DoesNotExist1")
|
||||
private class EnableAutoConfigurationWithAbsentClassNameExclude {
|
||||
|
||||
}
|
||||
|
||||
@SpringBootApplication(excludeName = "org.springframework.boot.autoconfigure.mustache.MustacheAutoConfiguration")
|
||||
private class SpringBootApplicationWithClassNameExclusions {
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,98 @@
|
|||
/*
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.boot.autoconfigure;
|
||||
|
||||
import java.util.Collections;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
/**
|
||||
* Test for {@link AutoConfigurationMetadataLoader}.
|
||||
*
|
||||
* @author Phillip Webb
|
||||
*/
|
||||
public class AutoConfigurationMetadataLoaderTests {
|
||||
|
||||
@Test
|
||||
public void loadShouldLoadProperties() throws Exception {
|
||||
assertThat(load()).isNotNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void wasProcessedWhenProcessedShouldReturnTrue() throws Exception {
|
||||
assertThat(load().wasProcessed("test")).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void wasProcessedWhenNotProcessedShouldReturnFalse() throws Exception {
|
||||
assertThat(load().wasProcessed("testx")).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getIntegerShouldReturnValue() throws Exception {
|
||||
assertThat(load().getInteger("test", "int")).isEqualTo(123);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getIntegerWhenMissingShouldReturnNull() throws Exception {
|
||||
assertThat(load().getInteger("test", "intx")).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getIntegerWithDefaultWhenMissingShouldReturnDefault() throws Exception {
|
||||
assertThat(load().getInteger("test", "intx", 345)).isEqualTo(345);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getSetShouldReturnValue() throws Exception {
|
||||
assertThat(load().getSet("test", "set")).containsExactly("a", "b", "c");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getSetWhenMissingShouldReturnNull() throws Exception {
|
||||
assertThat(load().getSet("test", "setx")).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getSetWithDefaultWhenMissingShouldReturnDefault() throws Exception {
|
||||
assertThat(load().getSet("test", "setx", Collections.singleton("x")))
|
||||
.containsExactly("x");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getShouldReturnValue() throws Exception {
|
||||
assertThat(load().get("test", "string")).isEqualTo("abc");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getWhenMissingShouldReturnNull() throws Exception {
|
||||
assertThat(load().get("test", "stringx")).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getWithDefaultWhenMissingShouldReturnDefault() throws Exception {
|
||||
assertThat(load().get("test", "stringx", "xyz")).isEqualTo("xyz");
|
||||
}
|
||||
|
||||
private AutoConfigurationMetadata load() {
|
||||
return AutoConfigurationMetadataLoader.loadMetadata(null,
|
||||
"META-INF/AutoConfigurationMetadataLoaderTests.properties");
|
||||
}
|
||||
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2012-2016 the original author or authors.
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -17,7 +17,10 @@
|
|||
package org.springframework.boot.autoconfigure;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
import java.util.Properties;
|
||||
import java.util.Set;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
|
@ -26,8 +29,12 @@ import org.junit.rules.ExpectedException;
|
|||
|
||||
import org.springframework.core.Ordered;
|
||||
import org.springframework.core.type.classreading.CachingMetadataReaderFactory;
|
||||
import org.springframework.core.type.classreading.MetadataReaderFactory;
|
||||
import org.springframework.util.ClassUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.mockito.Mockito.mock;
|
||||
|
||||
/**
|
||||
* Tests for {@link AutoConfigurationSorter}.
|
||||
|
@ -67,9 +74,13 @@ public class AutoConfigurationSorterTests {
|
|||
|
||||
private AutoConfigurationSorter sorter;
|
||||
|
||||
private AutoConfigurationMetadata autoConfigurationMetadata = mock(
|
||||
AutoConfigurationMetadata.class);
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
this.sorter = new AutoConfigurationSorter(new CachingMetadataReaderFactory());
|
||||
this.sorter = new AutoConfigurationSorter(new CachingMetadataReaderFactory(),
|
||||
this.autoConfigurationMetadata);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -132,6 +143,56 @@ public class AutoConfigurationSorterTests {
|
|||
this.sorter.getInPriorityOrder(Arrays.asList(A, B, C, D));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void usesAnnotationPropertiesWhenPossible() throws Exception {
|
||||
MetadataReaderFactory readerFactory = mock(MetadataReaderFactory.class);
|
||||
this.autoConfigurationMetadata = getAutoConfigurationMetadata(A2, B, C, W2, X);
|
||||
this.sorter = new AutoConfigurationSorter(readerFactory,
|
||||
this.autoConfigurationMetadata);
|
||||
List<String> actual = this.sorter
|
||||
.getInPriorityOrder(Arrays.asList(A2, B, C, W2, X));
|
||||
assertThat(actual).containsExactly(C, W2, B, A2, X);
|
||||
}
|
||||
|
||||
private AutoConfigurationMetadata getAutoConfigurationMetadata(String... classNames)
|
||||
throws Exception {
|
||||
Properties properties = new Properties();
|
||||
for (String className : classNames) {
|
||||
Class<?> type = ClassUtils.forName(className, null);
|
||||
properties.put(type.getName(), "");
|
||||
AutoConfigureOrder order = type
|
||||
.getDeclaredAnnotation(AutoConfigureOrder.class);
|
||||
if (order != null) {
|
||||
properties.put(className + ".AutoConfigureOrder",
|
||||
String.valueOf(order.value()));
|
||||
}
|
||||
AutoConfigureBefore autoConfigureBefore = type
|
||||
.getDeclaredAnnotation(AutoConfigureBefore.class);
|
||||
if (autoConfigureBefore != null) {
|
||||
properties.put(className + ".AutoConfigureBefore",
|
||||
merge(autoConfigureBefore.value(), autoConfigureBefore.name()));
|
||||
}
|
||||
AutoConfigureAfter autoConfigureAfter = type
|
||||
.getDeclaredAnnotation(AutoConfigureAfter.class);
|
||||
if (autoConfigureAfter != null) {
|
||||
properties.put(className + ".AutoConfigureAfter",
|
||||
merge(autoConfigureAfter.value(), autoConfigureAfter.name()));
|
||||
}
|
||||
}
|
||||
return AutoConfigurationMetadataLoader.loadMetadata(properties);
|
||||
}
|
||||
|
||||
private String merge(Class<?>[] value, String[] name) {
|
||||
Set<String> items = new LinkedHashSet<String>();
|
||||
for (Class<?> type : value) {
|
||||
items.add(type.getName());
|
||||
}
|
||||
for (String type : name) {
|
||||
items.add(type);
|
||||
}
|
||||
return StringUtils.collectionToCommaDelimitedString(items);
|
||||
}
|
||||
|
||||
@AutoConfigureOrder(Ordered.LOWEST_PRECEDENCE)
|
||||
public static class OrderLowest {
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2012-2016 the original author or authors.
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -16,23 +16,13 @@
|
|||
|
||||
package org.springframework.boot.autoconfigure;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.rules.ExpectedException;
|
||||
import org.mockito.MockitoAnnotations;
|
||||
|
||||
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
|
||||
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionEvaluationReport;
|
||||
import org.springframework.boot.autoconfigure.freemarker.FreeMarkerAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.mustache.MustacheAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.thymeleaf.ThymeleafAutoConfiguration;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.core.io.DefaultResourceLoader;
|
||||
import org.springframework.core.io.support.SpringFactoriesLoader;
|
||||
import org.springframework.core.type.StandardAnnotationMetadata;
|
||||
import org.springframework.mock.env.MockEnvironment;
|
||||
|
||||
|
@ -45,6 +35,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
|||
* @author Stephane Nicoll
|
||||
* @author Madhura Bhave
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public class EnableAutoConfigurationImportSelectorTests {
|
||||
|
||||
private final EnableAutoConfigurationImportSelector importSelector = new EnableAutoConfigurationImportSelector();
|
||||
|
@ -53,9 +44,6 @@ public class EnableAutoConfigurationImportSelectorTests {
|
|||
|
||||
private final MockEnvironment environment = new MockEnvironment();
|
||||
|
||||
@Rule
|
||||
public ExpectedException expected = ExpectedException.none();
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
MockitoAnnotations.initMocks(this);
|
||||
|
@ -64,98 +52,6 @@ public class EnableAutoConfigurationImportSelectorTests {
|
|||
this.importSelector.setResourceLoader(new DefaultResourceLoader());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void importsAreSelectedWhenUsingEnableAutoConfiguration() {
|
||||
String[] imports = selectImports(BasicEnableAutoConfiguration.class);
|
||||
assertThat(imports).hasSameSizeAs(SpringFactoriesLoader.loadFactoryNames(
|
||||
EnableAutoConfiguration.class, getClass().getClassLoader()));
|
||||
assertThat(ConditionEvaluationReport.get(this.beanFactory).getExclusions())
|
||||
.isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void classExclusionsAreApplied() {
|
||||
String[] imports = selectImports(
|
||||
EnableAutoConfigurationWithClassExclusions.class);
|
||||
assertThat(imports).hasSize(getAutoConfigurationClassNames().size() - 1);
|
||||
assertThat(ConditionEvaluationReport.get(this.beanFactory).getExclusions())
|
||||
.contains(FreeMarkerAutoConfiguration.class.getName());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void classExclusionsAreAppliedWhenUsingSpringBootApplication() {
|
||||
String[] imports = selectImports(SpringBootApplicationWithClassExclusions.class);
|
||||
assertThat(imports).hasSize(getAutoConfigurationClassNames().size() - 1);
|
||||
assertThat(ConditionEvaluationReport.get(this.beanFactory).getExclusions())
|
||||
.contains(FreeMarkerAutoConfiguration.class.getName());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void classNamesExclusionsAreApplied() {
|
||||
String[] imports = selectImports(
|
||||
EnableAutoConfigurationWithClassNameExclusions.class);
|
||||
assertThat(imports).hasSize(getAutoConfigurationClassNames().size() - 1);
|
||||
assertThat(ConditionEvaluationReport.get(this.beanFactory).getExclusions())
|
||||
.contains(MustacheAutoConfiguration.class.getName());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void classNamesExclusionsAreAppliedWhenUsingSpringBootApplication() {
|
||||
String[] imports = selectImports(
|
||||
SpringBootApplicationWithClassNameExclusions.class);
|
||||
assertThat(imports).hasSize(getAutoConfigurationClassNames().size() - 1);
|
||||
assertThat(ConditionEvaluationReport.get(this.beanFactory).getExclusions())
|
||||
.contains(MustacheAutoConfiguration.class.getName());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void propertyExclusionsAreApplied() {
|
||||
this.environment.setProperty("spring.autoconfigure.exclude",
|
||||
FreeMarkerAutoConfiguration.class.getName());
|
||||
String[] imports = selectImports(BasicEnableAutoConfiguration.class);
|
||||
assertThat(imports).hasSize(getAutoConfigurationClassNames().size() - 1);
|
||||
assertThat(ConditionEvaluationReport.get(this.beanFactory).getExclusions())
|
||||
.contains(FreeMarkerAutoConfiguration.class.getName());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void severalPropertyExclusionsAreApplied() {
|
||||
this.environment.setProperty("spring.autoconfigure.exclude",
|
||||
FreeMarkerAutoConfiguration.class.getName() + ","
|
||||
+ MustacheAutoConfiguration.class.getName());
|
||||
String[] imports = selectImports(BasicEnableAutoConfiguration.class);
|
||||
assertThat(imports).hasSize(getAutoConfigurationClassNames().size() - 2);
|
||||
assertThat(ConditionEvaluationReport.get(this.beanFactory).getExclusions())
|
||||
.contains(FreeMarkerAutoConfiguration.class.getName(),
|
||||
MustacheAutoConfiguration.class.getName());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void severalPropertyYamlExclusionsAreApplied() {
|
||||
this.environment.setProperty("spring.autoconfigure.exclude[0]",
|
||||
FreeMarkerAutoConfiguration.class.getName());
|
||||
this.environment.setProperty("spring.autoconfigure.exclude[1]",
|
||||
MustacheAutoConfiguration.class.getName());
|
||||
String[] imports = selectImports(BasicEnableAutoConfiguration.class);
|
||||
assertThat(imports).hasSize(getAutoConfigurationClassNames().size() - 2);
|
||||
assertThat(ConditionEvaluationReport.get(this.beanFactory).getExclusions())
|
||||
.contains(FreeMarkerAutoConfiguration.class.getName(),
|
||||
MustacheAutoConfiguration.class.getName());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void combinedExclusionsAreApplied() {
|
||||
this.environment.setProperty("spring.autoconfigure.exclude",
|
||||
ThymeleafAutoConfiguration.class.getName());
|
||||
String[] imports = selectImports(
|
||||
EnableAutoConfigurationWithClassAndClassNameExclusions.class);
|
||||
assertThat(imports).hasSize(getAutoConfigurationClassNames().size() - 3);
|
||||
assertThat(ConditionEvaluationReport.get(this.beanFactory).getExclusions())
|
||||
.contains(FreeMarkerAutoConfiguration.class.getName(),
|
||||
MustacheAutoConfiguration.class.getName(),
|
||||
ThymeleafAutoConfiguration.class.getName());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void propertyOverrideSetToTrue() throws Exception {
|
||||
this.environment.setProperty(EnableAutoConfiguration.ENABLED_OVERRIDE_PROPERTY,
|
||||
|
@ -172,99 +68,13 @@ public class EnableAutoConfigurationImportSelectorTests {
|
|||
assertThat(imports).isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void nonAutoConfigurationClassExclusionsShouldThrowException()
|
||||
throws Exception {
|
||||
this.expected.expect(IllegalStateException.class);
|
||||
selectImports(EnableAutoConfigurationWithFaultyClassExclude.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void nonAutoConfigurationClassNameExclusionsWhenPresentOnClassPathShouldThrowException()
|
||||
throws Exception {
|
||||
this.expected.expect(IllegalStateException.class);
|
||||
selectImports(EnableAutoConfigurationWithFaultyClassNameExclude.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void nonAutoConfigurationPropertyExclusionsWhenPresentOnClassPathShouldThrowException()
|
||||
throws Exception {
|
||||
this.environment.setProperty("spring.autoconfigure.exclude",
|
||||
"org.springframework.boot.autoconfigure."
|
||||
+ "EnableAutoConfigurationImportSelectorTests.TestConfiguration");
|
||||
this.expected.expect(IllegalStateException.class);
|
||||
selectImports(BasicEnableAutoConfiguration.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void nameAndPropertyExclusionsWhenNotPresentOnClasspathShouldNotThrowException()
|
||||
throws Exception {
|
||||
this.environment.setProperty("spring.autoconfigure.exclude",
|
||||
"org.springframework.boot.autoconfigure.DoesNotExist2");
|
||||
selectImports(EnableAutoConfigurationWithAbsentClassNameExclude.class);
|
||||
assertThat(ConditionEvaluationReport.get(this.beanFactory).getExclusions())
|
||||
.containsExactlyInAnyOrder(
|
||||
"org.springframework.boot.autoconfigure.DoesNotExist1",
|
||||
"org.springframework.boot.autoconfigure.DoesNotExist2");
|
||||
}
|
||||
|
||||
private String[] selectImports(Class<?> source) {
|
||||
return this.importSelector.selectImports(new StandardAnnotationMetadata(source));
|
||||
}
|
||||
|
||||
private List<String> getAutoConfigurationClassNames() {
|
||||
return SpringFactoriesLoader.loadFactoryNames(EnableAutoConfiguration.class,
|
||||
getClass().getClassLoader());
|
||||
}
|
||||
|
||||
@Configuration
|
||||
private class TestConfiguration {
|
||||
|
||||
}
|
||||
|
||||
@EnableAutoConfiguration
|
||||
private class BasicEnableAutoConfiguration {
|
||||
|
||||
}
|
||||
|
||||
@EnableAutoConfiguration(exclude = FreeMarkerAutoConfiguration.class)
|
||||
private class EnableAutoConfigurationWithClassExclusions {
|
||||
|
||||
}
|
||||
|
||||
@SpringBootApplication(exclude = FreeMarkerAutoConfiguration.class)
|
||||
private class SpringBootApplicationWithClassExclusions {
|
||||
|
||||
}
|
||||
|
||||
@EnableAutoConfiguration(excludeName = "org.springframework.boot.autoconfigure.mustache.MustacheAutoConfiguration")
|
||||
private class EnableAutoConfigurationWithClassNameExclusions {
|
||||
|
||||
}
|
||||
|
||||
@EnableAutoConfiguration(exclude = MustacheAutoConfiguration.class, excludeName = "org.springframework.boot.autoconfigure.freemarker.FreeMarkerAutoConfiguration")
|
||||
private class EnableAutoConfigurationWithClassAndClassNameExclusions {
|
||||
|
||||
}
|
||||
|
||||
@EnableAutoConfiguration(exclude = TestConfiguration.class)
|
||||
private class EnableAutoConfigurationWithFaultyClassExclude {
|
||||
|
||||
}
|
||||
|
||||
@EnableAutoConfiguration(excludeName = "org.springframework.boot.autoconfigure.EnableAutoConfigurationImportSelectorTests.TestConfiguration")
|
||||
private class EnableAutoConfigurationWithFaultyClassNameExclude {
|
||||
|
||||
}
|
||||
|
||||
@EnableAutoConfiguration(excludeName = "org.springframework.boot.autoconfigure.DoesNotExist1")
|
||||
private class EnableAutoConfigurationWithAbsentClassNameExclude {
|
||||
|
||||
}
|
||||
|
||||
@SpringBootApplication(excludeName = "org.springframework.boot.autoconfigure.mustache.MustacheAutoConfiguration")
|
||||
private class SpringBootApplicationWithClassNameExclusions {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2012-2016 the original author or authors.
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -21,6 +21,7 @@ import org.junit.runner.RunWith;
|
|||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2012-2016 the original author or authors.
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -16,6 +16,8 @@
|
|||
|
||||
package org.springframework.boot.autoconfigure;
|
||||
|
||||
import java.util.Properties;
|
||||
|
||||
import org.springframework.core.type.classreading.MetadataReaderFactory;
|
||||
|
||||
/**
|
||||
|
@ -26,7 +28,8 @@ import org.springframework.core.type.classreading.MetadataReaderFactory;
|
|||
public class TestAutoConfigurationSorter extends AutoConfigurationSorter {
|
||||
|
||||
public TestAutoConfigurationSorter(MetadataReaderFactory metadataReaderFactory) {
|
||||
super(metadataReaderFactory);
|
||||
super(metadataReaderFactory,
|
||||
AutoConfigurationMetadataLoader.loadMetadata(new Properties()));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2012-2016 the original author or authors.
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -47,8 +47,8 @@ import org.springframework.batch.core.repository.support.MapJobRepositoryFactory
|
|||
import org.springframework.batch.support.transaction.ResourcelessTransactionManager;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.CommandLineRunner;
|
||||
import org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.TestAutoConfigurationPackage;
|
||||
import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.jdbc.EmbeddedDataSourceConfiguration;
|
||||
import org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.orm.jpa.test.City;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2012-2016 the original author or authors.
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -20,7 +20,7 @@ import com.datastax.driver.core.Cluster;
|
|||
import org.junit.After;
|
||||
import org.junit.Test;
|
||||
|
||||
import org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration;
|
||||
import org.springframework.boot.test.util.EnvironmentTestUtils;
|
||||
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
|
|
|
@ -0,0 +1,84 @@
|
|||
/*
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.boot.autoconfigure.condition;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
|
||||
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
|
||||
import org.springframework.boot.autoconfigure.AutoConfigurationImportEvent;
|
||||
import org.springframework.boot.autoconfigure.AutoConfigurationImportListener;
|
||||
import org.springframework.core.io.support.SpringFactoriesLoader;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
/**
|
||||
* Tests for {@link ConditionEvaluationReportAutoConfigurationImportListener}.
|
||||
*
|
||||
* @author Phillip Webb
|
||||
*/
|
||||
public class ConditionEvaluationReportAutoConfigurationImportListenerTests {
|
||||
|
||||
private ConditionEvaluationReportAutoConfigurationImportListener listener;
|
||||
|
||||
private final ConfigurableListableBeanFactory beanFactory = new DefaultListableBeanFactory();
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
this.listener = new ConditionEvaluationReportAutoConfigurationImportListener();
|
||||
this.listener.setBeanFactory(this.beanFactory);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldBeInSpringFactories() throws Exception {
|
||||
List<AutoConfigurationImportListener> factories = SpringFactoriesLoader
|
||||
.loadFactories(AutoConfigurationImportListener.class, null);
|
||||
assertThat(factories).hasAtLeastOneElementOfType(
|
||||
ConditionEvaluationReportAutoConfigurationImportListener.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void onAutoConfigurationImportEventShouldRecordCandidates() throws Exception {
|
||||
List<String> candidateConfigurations = Collections.singletonList("Test");
|
||||
Set<String> exclusions = Collections.emptySet();
|
||||
AutoConfigurationImportEvent event = new AutoConfigurationImportEvent(this,
|
||||
candidateConfigurations, exclusions);
|
||||
this.listener.onAutoConfigurationImportEvent(event);
|
||||
ConditionEvaluationReport report = ConditionEvaluationReport
|
||||
.get(this.beanFactory);
|
||||
assertThat(report.getUnconditionalClasses())
|
||||
.containsExactlyElementsOf(candidateConfigurations);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void onAutoConfigurationImportEventShouldRecordExclusions() throws Exception {
|
||||
List<String> candidateConfigurations = Collections.emptyList();
|
||||
Set<String> exclusions = Collections.singleton("Test");
|
||||
AutoConfigurationImportEvent event = new AutoConfigurationImportEvent(this,
|
||||
candidateConfigurations, exclusions);
|
||||
this.listener.onAutoConfigurationImportEvent(event);
|
||||
ConditionEvaluationReport report = ConditionEvaluationReport
|
||||
.get(this.beanFactory);
|
||||
assertThat(report.getExclusions()).containsExactlyElementsOf(exclusions);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2012-2016 the original author or authors.
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -24,9 +24,9 @@ import org.springframework.beans.factory.FactoryBean;
|
|||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
|
||||
import org.springframework.beans.factory.support.BeanDefinitionRegistry;
|
||||
import org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.condition.scan.ScannedFactoryBeanConfiguration;
|
||||
import org.springframework.boot.autoconfigure.condition.scan.ScannedFactoryBeanWithBeanMethodArgumentsConfiguration;
|
||||
import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration;
|
||||
import org.springframework.boot.test.util.EnvironmentTestUtils;
|
||||
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
|
|
|
@ -0,0 +1,86 @@
|
|||
/*
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.boot.autoconfigure.condition;
|
||||
|
||||
import java.util.Collections;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
|
||||
import org.springframework.boot.autoconfigure.AutoConfigurationImportFilter;
|
||||
import org.springframework.boot.autoconfigure.AutoConfigurationMetadata;
|
||||
import org.springframework.core.io.support.SpringFactoriesLoader;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.mockito.BDDMockito.given;
|
||||
import static org.mockito.Mockito.mock;
|
||||
|
||||
/**
|
||||
* Tests for the {@link AutoConfigurationImportFilter} part of {@link OnClassCondition}.
|
||||
*
|
||||
* @author Phillip Webb
|
||||
*/
|
||||
public class OnClassConditionAutoConfigurationImportFilterTests {
|
||||
|
||||
private OnClassCondition filter = new OnClassCondition();
|
||||
|
||||
private DefaultListableBeanFactory beanFactory = new DefaultListableBeanFactory();
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
this.filter.setBeanClassLoader(getClass().getClassLoader());
|
||||
this.filter.setBeanFactory(this.beanFactory);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldBeRegistered() throws Exception {
|
||||
assertThat(SpringFactoriesLoader
|
||||
.loadFactories(AutoConfigurationImportFilter.class, null))
|
||||
.hasAtLeastOneElementOfType(OnClassCondition.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void matchShouldMatchClasses() throws Exception {
|
||||
String[] autoConfigurationClasses = new String[] { "test.match", "test.nomatch" };
|
||||
boolean[] result = this.filter.match(autoConfigurationClasses,
|
||||
getAutoConfigurationMetadata());
|
||||
assertThat(result).containsExactly(true, false);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void matchShouldRecordOutcome() throws Exception {
|
||||
String[] autoConfigurationClasses = new String[] { "test.match", "test.nomatch" };
|
||||
this.filter.match(autoConfigurationClasses, getAutoConfigurationMetadata());
|
||||
ConditionEvaluationReport report = ConditionEvaluationReport
|
||||
.get(this.beanFactory);
|
||||
assertThat(report.getConditionAndOutcomesBySource()).hasSize(1)
|
||||
.containsKey("test.nomatch");
|
||||
}
|
||||
|
||||
private AutoConfigurationMetadata getAutoConfigurationMetadata() {
|
||||
AutoConfigurationMetadata metadata = mock(AutoConfigurationMetadata.class);
|
||||
given(metadata.wasProcessed("test.match")).willReturn(true);
|
||||
given(metadata.getSet("test.match", "ConditionalOnClass"))
|
||||
.willReturn(Collections.<String>singleton("java.io.InputStream"));
|
||||
given(metadata.wasProcessed("test.nomatch")).willReturn(true);
|
||||
given(metadata.getSet("test.nomatch", "ConditionalOnClass"))
|
||||
.willReturn(Collections.<String>singleton("java.io.DoesNotExist"));
|
||||
return metadata;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2012-2016 the original author or authors.
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -14,7 +14,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.boot.autoconfigure;
|
||||
package org.springframework.boot.autoconfigure.context;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
|
@ -22,6 +22,7 @@ import org.junit.Test;
|
|||
import org.junit.runner.RunWith;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.autoconfigure.ImportAutoConfiguration;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.annotation.Configuration;
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2012-2016 the original author or authors.
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -14,7 +14,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.boot.autoconfigure;
|
||||
package org.springframework.boot.autoconfigure.context;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
|
@ -22,6 +22,7 @@ import org.junit.Test;
|
|||
import org.junit.runner.RunWith;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.autoconfigure.ImportAutoConfiguration;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.annotation.Configuration;
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2012-2016 the original author or authors.
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -14,7 +14,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.boot.autoconfigure;
|
||||
package org.springframework.boot.autoconfigure.context;
|
||||
|
||||
import java.util.Locale;
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2012-2016 the original author or authors.
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -14,7 +14,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.boot.autoconfigure;
|
||||
package org.springframework.boot.autoconfigure.context;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Test;
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2012-2016 the original author or authors.
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -18,7 +18,7 @@ package org.springframework.boot.autoconfigure.couchbase;
|
|||
|
||||
import org.junit.After;
|
||||
|
||||
import org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration;
|
||||
import org.springframework.boot.test.util.EnvironmentTestUtils;
|
||||
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2012-2016 the original author or authors.
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -22,8 +22,8 @@ import com.datastax.driver.core.Session;
|
|||
import org.junit.After;
|
||||
import org.junit.Test;
|
||||
|
||||
import org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.cassandra.CassandraAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.data.cassandra.city.City;
|
||||
import org.springframework.boot.autoconfigure.domain.EntityScan;
|
||||
import org.springframework.boot.test.util.EnvironmentTestUtils;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2012-2016 the original author or authors.
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -24,9 +24,9 @@ import org.junit.After;
|
|||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.TestAutoConfigurationPackage;
|
||||
import org.springframework.boot.autoconfigure.cassandra.CassandraAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.data.alt.cassandra.CityCassandraRepository;
|
||||
import org.springframework.boot.autoconfigure.data.cassandra.city.City;
|
||||
import org.springframework.boot.autoconfigure.data.cassandra.city.CityRepository;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2012-2016 the original author or authors.
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -22,7 +22,7 @@ import java.util.Set;
|
|||
import org.junit.After;
|
||||
import org.junit.Test;
|
||||
|
||||
import org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.couchbase.CouchbaseAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.couchbase.CouchbaseProperties;
|
||||
import org.springframework.boot.autoconfigure.couchbase.CouchbaseTestConfigurer;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2012-2016 the original author or authors.
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -19,8 +19,8 @@ package org.springframework.boot.autoconfigure.data.couchbase;
|
|||
import org.junit.After;
|
||||
import org.junit.Test;
|
||||
|
||||
import org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.TestAutoConfigurationPackage;
|
||||
import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.couchbase.CouchbaseAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.couchbase.CouchbaseTestConfigurer;
|
||||
import org.springframework.boot.autoconfigure.data.couchbase.city.City;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2012-2016 the original author or authors.
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -24,7 +24,7 @@ import org.junit.Test;
|
|||
import org.junit.rules.ExpectedException;
|
||||
|
||||
import org.springframework.beans.factory.BeanCreationException;
|
||||
import org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration;
|
||||
import org.springframework.boot.test.util.EnvironmentTestUtils;
|
||||
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2012-2016 the original author or authors.
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -19,7 +19,7 @@ package org.springframework.boot.autoconfigure.data.elasticsearch;
|
|||
import org.junit.After;
|
||||
import org.junit.Test;
|
||||
|
||||
import org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration;
|
||||
import org.springframework.boot.test.util.EnvironmentTestUtils;
|
||||
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
|
||||
import org.springframework.data.elasticsearch.core.ElasticsearchTemplate;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2012-2016 the original author or authors.
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -20,8 +20,8 @@ import org.elasticsearch.client.Client;
|
|||
import org.junit.After;
|
||||
import org.junit.Test;
|
||||
|
||||
import org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.TestAutoConfigurationPackage;
|
||||
import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.data.alt.elasticsearch.CityElasticsearchDbRepository;
|
||||
import org.springframework.boot.autoconfigure.data.elasticsearch.city.City;
|
||||
import org.springframework.boot.autoconfigure.data.elasticsearch.city.CityRepository;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2012-2016 the original author or authors.
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -22,8 +22,8 @@ import org.junit.After;
|
|||
import org.junit.Test;
|
||||
|
||||
import org.springframework.beans.factory.NoSuchBeanDefinitionException;
|
||||
import org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.TestAutoConfigurationPackage;
|
||||
import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.data.alt.mongo.CityMongoDbRepository;
|
||||
import org.springframework.boot.autoconfigure.data.alt.solr.CitySolrRepository;
|
||||
import org.springframework.boot.autoconfigure.data.jpa.city.City;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2012-2016 the original author or authors.
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -19,8 +19,8 @@ package org.springframework.boot.autoconfigure.data.jpa;
|
|||
import org.junit.After;
|
||||
import org.junit.Test;
|
||||
|
||||
import org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.TestAutoConfigurationPackage;
|
||||
import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.data.jpa.city.City;
|
||||
import org.springframework.boot.autoconfigure.data.jpa.city.CityRepository;
|
||||
import org.springframework.boot.autoconfigure.data.web.SpringDataWebAutoConfiguration;
|
||||
|
|
|
@ -19,7 +19,7 @@ package org.springframework.boot.autoconfigure.data.ldap;
|
|||
import org.junit.After;
|
||||
import org.junit.Test;
|
||||
|
||||
import org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.ldap.LdapAutoConfiguration;
|
||||
import org.springframework.boot.test.util.EnvironmentTestUtils;
|
||||
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
|
||||
|
|
|
@ -19,8 +19,8 @@ package org.springframework.boot.autoconfigure.data.ldap;
|
|||
import org.junit.After;
|
||||
import org.junit.Test;
|
||||
|
||||
import org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.TestAutoConfigurationPackage;
|
||||
import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.data.alt.ldap.PersonLdapRepository;
|
||||
import org.springframework.boot.autoconfigure.data.empty.EmptyDataPackage;
|
||||
import org.springframework.boot.autoconfigure.data.ldap.person.Person;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2012-2016 the original author or authors.
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -29,7 +29,7 @@ import org.junit.rules.ExpectedException;
|
|||
import org.springframework.beans.factory.BeanCreationException;
|
||||
import org.springframework.beans.factory.UnsatisfiedDependencyException;
|
||||
import org.springframework.boot.autoconfigure.AutoConfigurationPackages;
|
||||
import org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.data.mongo.city.City;
|
||||
import org.springframework.boot.autoconfigure.data.mongo.country.Country;
|
||||
import org.springframework.boot.autoconfigure.domain.EntityScan;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2012-2016 the original author or authors.
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -24,8 +24,8 @@ import org.junit.After;
|
|||
import org.junit.Test;
|
||||
|
||||
import org.springframework.beans.factory.NoSuchBeanDefinitionException;
|
||||
import org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.TestAutoConfigurationPackage;
|
||||
import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.data.alt.mongo.CityMongoDbRepository;
|
||||
import org.springframework.boot.autoconfigure.data.empty.EmptyDataPackage;
|
||||
import org.springframework.boot.autoconfigure.data.mongo.city.City;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2012-2016 the original author or authors.
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -28,7 +28,7 @@ import org.neo4j.ogm.session.event.PersistenceEvent;
|
|||
|
||||
import org.springframework.beans.factory.support.BeanDefinitionRegistry;
|
||||
import org.springframework.boot.autoconfigure.AutoConfigurationPackages;
|
||||
import org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.data.neo4j.city.City;
|
||||
import org.springframework.boot.autoconfigure.transaction.TransactionAutoConfiguration;
|
||||
import org.springframework.boot.test.util.EnvironmentTestUtils;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2012-2016 the original author or authors.
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -21,8 +21,8 @@ import org.junit.Test;
|
|||
import org.neo4j.ogm.session.SessionFactory;
|
||||
|
||||
import org.springframework.beans.factory.NoSuchBeanDefinitionException;
|
||||
import org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.TestAutoConfigurationPackage;
|
||||
import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.data.alt.neo4j.CityNeo4jRepository;
|
||||
import org.springframework.boot.autoconfigure.data.empty.EmptyDataPackage;
|
||||
import org.springframework.boot.autoconfigure.data.neo4j.city.City;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2012-2016 the original author or authors.
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -24,7 +24,7 @@ import org.junit.Before;
|
|||
import org.junit.Test;
|
||||
import redis.clients.jedis.Jedis;
|
||||
|
||||
import org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration;
|
||||
import org.springframework.boot.test.util.EnvironmentTestUtils;
|
||||
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
|
||||
import org.springframework.data.redis.connection.jedis.JedisConnectionFactory;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2012-2016 the original author or authors.
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -20,8 +20,8 @@ import org.junit.After;
|
|||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
|
||||
import org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.TestAutoConfigurationPackage;
|
||||
import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.data.alt.redis.CityRedisRepository;
|
||||
import org.springframework.boot.autoconfigure.data.empty.EmptyDataPackage;
|
||||
import org.springframework.boot.autoconfigure.data.redis.city.City;
|
||||
|
|
|
@ -26,8 +26,8 @@ import org.junit.After;
|
|||
import org.junit.Test;
|
||||
|
||||
import org.springframework.boot.autoconfigure.ImportAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.TestAutoConfigurationPackage;
|
||||
import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.data.jpa.JpaRepositoriesAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.data.jpa.city.City;
|
||||
import org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2012-2016 the original author or authors.
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -22,8 +22,8 @@ import org.junit.After;
|
|||
import org.junit.Test;
|
||||
|
||||
import org.springframework.beans.factory.NoSuchBeanDefinitionException;
|
||||
import org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.TestAutoConfigurationPackage;
|
||||
import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.data.alt.solr.CitySolrRepository;
|
||||
import org.springframework.boot.autoconfigure.data.empty.EmptyDataPackage;
|
||||
import org.springframework.boot.autoconfigure.data.solr.city.City;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2012-2016 the original author or authors.
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -33,7 +33,7 @@ import org.junit.Test;
|
|||
import org.junit.rules.ExpectedException;
|
||||
|
||||
import org.springframework.beans.factory.BeanCreationException;
|
||||
import org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.jdbc.DataSourceBuilder;
|
||||
import org.springframework.boot.autoconfigure.jdbc.EmbeddedDataSourceConfiguration;
|
||||
import org.springframework.boot.orm.jpa.EntityManagerFactoryBuilder;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2012-2016 the original author or authors.
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -22,7 +22,7 @@ import java.util.Properties;
|
|||
import org.junit.After;
|
||||
import org.junit.Test;
|
||||
|
||||
import org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration;
|
||||
import org.springframework.boot.info.BuildProperties;
|
||||
import org.springframework.boot.info.GitProperties;
|
||||
import org.springframework.boot.test.util.EnvironmentTestUtils;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2012-2016 the original author or authors.
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -36,7 +36,7 @@ import org.junit.Before;
|
|||
import org.junit.Test;
|
||||
|
||||
import org.springframework.beans.factory.BeanCreationException;
|
||||
import org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration;
|
||||
import org.springframework.boot.jdbc.DatabaseDriver;
|
||||
import org.springframework.boot.test.util.EnvironmentTestUtils;
|
||||
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2012-2016 the original author or authors.
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -31,7 +31,7 @@ import org.junit.Test;
|
|||
import org.junit.rules.ExpectedException;
|
||||
|
||||
import org.springframework.beans.factory.BeanCreationException;
|
||||
import org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||
import org.springframework.boot.test.util.EnvironmentTestUtils;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2012-2016 the original author or authors.
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -25,7 +25,7 @@ import org.junit.After;
|
|||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration;
|
||||
import org.springframework.boot.test.util.EnvironmentTestUtils;
|
||||
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2012-2016 the original author or authors.
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -33,7 +33,7 @@ import org.junit.runner.RunWith;
|
|||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.web.EmbeddedServletContainerAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.web.ServerPropertiesAutoConfiguration;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2012-2016 the original author or authors.
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -33,7 +33,7 @@ import org.junit.runner.RunWith;
|
|||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.web.EmbeddedServletContainerAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.web.ServerPropertiesAutoConfiguration;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2012-2016 the original author or authors.
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -28,7 +28,7 @@ import org.junit.runner.RunWith;
|
|||
|
||||
import org.springframework.beans.DirectFieldAccessor;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.web.EmbeddedServletContainerAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.web.ServerPropertiesAutoConfiguration;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2012-2016 the original author or authors.
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -32,7 +32,7 @@ import org.junit.runner.RunWith;
|
|||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.web.EmbeddedServletContainerAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.web.ServerPropertiesAutoConfiguration;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2012-2016 the original author or authors.
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -33,7 +33,7 @@ import org.junit.runner.RunWith;
|
|||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.web.EmbeddedServletContainerAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.web.ServerPropertiesAutoConfiguration;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2012-2016 the original author or authors.
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -33,7 +33,7 @@ import org.junit.runner.RunWith;
|
|||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.web.EmbeddedServletContainerAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.web.ServerPropertiesAutoConfiguration;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2012-2016 the original author or authors.
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -32,7 +32,7 @@ import org.junit.runner.RunWith;
|
|||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.web.EmbeddedServletContainerAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.web.ServerPropertiesAutoConfiguration;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2012-2016 the original author or authors.
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -32,7 +32,7 @@ import org.junit.runner.RunWith;
|
|||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.web.EmbeddedServletContainerAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.web.ServerPropertiesAutoConfiguration;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2012-2016 the original author or authors.
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -33,7 +33,7 @@ import org.junit.runner.RunWith;
|
|||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.web.EmbeddedServletContainerAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.web.ServerPropertiesAutoConfiguration;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2012-2016 the original author or authors.
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -30,7 +30,7 @@ import org.junit.runner.RunWith;
|
|||
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.boot.autoconfigure.ImportAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.jersey.JerseyAutoConfigurationServletContainerTests.Application;
|
||||
import org.springframework.boot.autoconfigure.web.EmbeddedServletContainerAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.web.ServerPropertiesAutoConfiguration;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2012-2016 the original author or authors.
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -32,7 +32,7 @@ import org.junit.runner.RunWith;
|
|||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.web.EmbeddedServletContainerAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.web.ServerPropertiesAutoConfiguration;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2012-2016 the original author or authors.
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -37,7 +37,7 @@ import org.junit.Rule;
|
|||
import org.junit.Test;
|
||||
import org.junit.rules.ExpectedException;
|
||||
|
||||
import org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.jdbc.DataSourceBuilder;
|
||||
import org.springframework.boot.test.util.EnvironmentTestUtils;
|
||||
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
|
||||
|
|
|
@ -19,7 +19,7 @@ package org.springframework.boot.autoconfigure.ldap;
|
|||
import org.junit.After;
|
||||
import org.junit.Test;
|
||||
|
||||
import org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration;
|
||||
import org.springframework.boot.test.util.EnvironmentTestUtils;
|
||||
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
|
||||
import org.springframework.ldap.core.ContextSource;
|
||||
|
|
|
@ -26,7 +26,7 @@ import org.junit.Before;
|
|||
import org.junit.Test;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.data.ldap.LdapDataAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.ldap.LdapAutoConfiguration;
|
||||
import org.springframework.boot.test.util.EnvironmentTestUtils;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2012-2016 the original author or authors.
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -30,7 +30,7 @@ import org.junit.rules.ExpectedException;
|
|||
import org.junit.rules.TemporaryFolder;
|
||||
|
||||
import org.springframework.beans.factory.BeanCreationException;
|
||||
import org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.jdbc.DataSourceBuilder;
|
||||
import org.springframework.boot.autoconfigure.jdbc.EmbeddedDataSourceConfiguration;
|
||||
import org.springframework.boot.liquibase.CommonsLoggingLiquibaseLogger;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2012-2016 the original author or authors.
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -32,8 +32,8 @@ import org.mockito.invocation.InvocationOnMock;
|
|||
import org.mockito.stubbing.Answer;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionEvaluationReport;
|
||||
import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.web.HttpMessageConvertersAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.web.WebMvcAutoConfiguration;
|
||||
import org.springframework.boot.context.event.ApplicationFailedEvent;
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue