Move to constructor injection in simple configuration classes

This commit updates "simple" configuration classes to use constructor
injection. Simple means that there are no optional dependencies
(@Autowired(required=false) is not used), and none of the dependencies
use generics.

Configuration classes that are not simple will be updated in a second
pass once https://jira.spring.io/browse/SPR-14015 has been fixed.

See gh-5306
This commit is contained in:
Andy Wilkinson 2016-03-04 10:49:17 +00:00
parent 398aed7fdb
commit 5009933788
74 changed files with 525 additions and 321 deletions

View File

@ -103,8 +103,12 @@ import org.springframework.mail.javamail.JavaMailSenderImpl;
@EnableConfigurationProperties({ HealthIndicatorProperties.class }) @EnableConfigurationProperties({ HealthIndicatorProperties.class })
public class HealthIndicatorAutoConfiguration { public class HealthIndicatorAutoConfiguration {
@Autowired private final HealthIndicatorProperties properties;
private HealthIndicatorProperties properties = new HealthIndicatorProperties();
public HealthIndicatorAutoConfiguration(
HealthIndicatorProperties properties) {
this.properties = properties;
}
@Bean @Bean
@ConditionalOnMissingBean(HealthAggregator.class) @ConditionalOnMissingBean(HealthAggregator.class)

View File

@ -20,7 +20,6 @@ import java.util.Properties;
import org.jolokia.http.AgentServlet; import org.jolokia.http.AgentServlet;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.actuate.autoconfigure.JolokiaAutoConfiguration.JolokiaCondition; import org.springframework.boot.actuate.autoconfigure.JolokiaAutoConfiguration.JolokiaCondition;
import org.springframework.boot.actuate.endpoint.mvc.JolokiaMvcEndpoint; import org.springframework.boot.actuate.endpoint.mvc.JolokiaMvcEndpoint;
import org.springframework.boot.autoconfigure.AutoConfigureAfter; import org.springframework.boot.autoconfigure.AutoConfigureAfter;
@ -69,8 +68,11 @@ import org.springframework.web.servlet.mvc.ServletWrappingController;
@EnableConfigurationProperties(JolokiaProperties.class) @EnableConfigurationProperties(JolokiaProperties.class)
public class JolokiaAutoConfiguration { public class JolokiaAutoConfiguration {
@Autowired private final JolokiaProperties properties;
JolokiaProperties properties = new JolokiaProperties();
public JolokiaAutoConfiguration(JolokiaProperties properties) {
this.properties = properties;
}
@Bean @Bean
@ConditionalOnMissingBean @ConditionalOnMissingBean

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2015 the original author or authors. * Copyright 2012-2016 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -19,7 +19,6 @@ package org.springframework.boot.actuate.autoconfigure;
import javax.servlet.Servlet; import javax.servlet.Servlet;
import javax.servlet.ServletRegistration; import javax.servlet.ServletRegistration;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.actuate.metrics.CounterService; import org.springframework.boot.actuate.metrics.CounterService;
import org.springframework.boot.actuate.metrics.GaugeService; import org.springframework.boot.actuate.metrics.GaugeService;
import org.springframework.boot.autoconfigure.AutoConfigureAfter; import org.springframework.boot.autoconfigure.AutoConfigureAfter;
@ -48,11 +47,15 @@ import org.springframework.web.servlet.HandlerMapping;
@ConditionalOnProperty(name = "endpoints.metrics.filter.enabled", matchIfMissing = true) @ConditionalOnProperty(name = "endpoints.metrics.filter.enabled", matchIfMissing = true)
public class MetricFilterAutoConfiguration { public class MetricFilterAutoConfiguration {
@Autowired private final CounterService counterService;
private CounterService counterService;
@Autowired private final GaugeService gaugeService;
private GaugeService gaugeService;
public MetricFilterAutoConfiguration(CounterService counterService,
GaugeService gaugeService) {
this.counterService = counterService;
this.gaugeService = gaugeService;
}
@Bean @Bean
public MetricsFilter metricFilter() { public MetricsFilter metricFilter() {

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2015 the original author or authors. * Copyright 2012-2016 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -18,7 +18,6 @@ package org.springframework.boot.actuate.autoconfigure;
import com.codahale.metrics.MetricRegistry; import com.codahale.metrics.MetricRegistry;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.actuate.metrics.CounterService; import org.springframework.boot.actuate.metrics.CounterService;
import org.springframework.boot.actuate.metrics.GaugeService; import org.springframework.boot.actuate.metrics.GaugeService;
import org.springframework.boot.actuate.metrics.buffer.BufferCounterService; import org.springframework.boot.actuate.metrics.buffer.BufferCounterService;
@ -86,9 +85,11 @@ public class MetricRepositoryAutoConfiguration {
@ConditionalOnMissingBean(GaugeService.class) @ConditionalOnMissingBean(GaugeService.class)
static class LegacyMetricServicesConfiguration { static class LegacyMetricServicesConfiguration {
@Autowired private final MetricWriter writer;
@ActuatorMetricWriter
private MetricWriter writer; LegacyMetricServicesConfiguration(@ActuatorMetricWriter MetricWriter writer) {
this.writer = writer;
}
@Bean @Bean
@ConditionalOnMissingBean(CounterService.class) @ConditionalOnMissingBean(CounterService.class)

View File

@ -22,7 +22,6 @@ import javax.annotation.PostConstruct;
import org.junit.Test; import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.actuate.endpoint.AutoConfigurationReportEndpoint.Report; import org.springframework.boot.actuate.endpoint.AutoConfigurationReportEndpoint.Report;
import org.springframework.boot.autoconfigure.condition.ConditionEvaluationReport; import org.springframework.boot.autoconfigure.condition.ConditionEvaluationReport;
import org.springframework.boot.autoconfigure.condition.ConditionOutcome; import org.springframework.boot.autoconfigure.condition.ConditionOutcome;
@ -66,8 +65,11 @@ public class AutoConfigurationReportEndpointTests
@EnableConfigurationProperties @EnableConfigurationProperties
public static class Config { public static class Config {
@Autowired private final ConfigurableApplicationContext context;
private ConfigurableApplicationContext context;
public Config(ConfigurableApplicationContext context) {
this.context = context;
}
@PostConstruct @PostConstruct
public void setupAutoConfigurationReport() { public void setupAutoConfigurationReport() {

View File

@ -19,7 +19,6 @@ package org.springframework.boot.actuate.endpoint;
import org.flywaydb.core.Flyway; import org.flywaydb.core.Flyway;
import org.junit.Test; import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.flyway.FlywayAutoConfiguration; import org.springframework.boot.autoconfigure.flyway.FlywayAutoConfiguration;
import org.springframework.boot.autoconfigure.jdbc.EmbeddedDataSourceConfiguration; import org.springframework.boot.autoconfigure.jdbc.EmbeddedDataSourceConfiguration;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
@ -48,12 +47,9 @@ public class FlywayEndpointTests extends AbstractEndpointTests<FlywayEndpoint> {
@Import({ EmbeddedDataSourceConfiguration.class, FlywayAutoConfiguration.class }) @Import({ EmbeddedDataSourceConfiguration.class, FlywayAutoConfiguration.class })
public static class Config { public static class Config {
@Autowired
private Flyway flyway;
@Bean @Bean
public FlywayEndpoint endpoint() { public FlywayEndpoint endpoint(Flyway flyway) {
return new FlywayEndpoint(this.flyway); return new FlywayEndpoint(flyway);
} }
} }

View File

@ -19,7 +19,6 @@ package org.springframework.boot.actuate.endpoint;
import liquibase.integration.spring.SpringLiquibase; import liquibase.integration.spring.SpringLiquibase;
import org.junit.Test; import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.jdbc.EmbeddedDataSourceConfiguration; import org.springframework.boot.autoconfigure.jdbc.EmbeddedDataSourceConfiguration;
import org.springframework.boot.autoconfigure.liquibase.LiquibaseAutoConfiguration; import org.springframework.boot.autoconfigure.liquibase.LiquibaseAutoConfiguration;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
@ -49,8 +48,11 @@ public class LiquibaseEndpointTests extends AbstractEndpointTests<LiquibaseEndpo
@Import({ EmbeddedDataSourceConfiguration.class, LiquibaseAutoConfiguration.class }) @Import({ EmbeddedDataSourceConfiguration.class, LiquibaseAutoConfiguration.class })
public static class Config { public static class Config {
@Autowired private final SpringLiquibase liquibase;
private SpringLiquibase liquibase;
public Config(SpringLiquibase liquibase) {
this.liquibase = liquibase;
}
@Bean @Bean
public LiquibaseEndpoint endpoint() { public LiquibaseEndpoint endpoint() {

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2015 the original author or authors. * Copyright 2012-2016 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -132,8 +132,11 @@ public class BatchAutoConfiguration {
@Configuration @Configuration
protected static class JpaBatchConfiguration { protected static class JpaBatchConfiguration {
@Autowired private final BatchProperties properties;
private BatchProperties properties;
protected JpaBatchConfiguration(BatchProperties properties) {
this.properties = properties;
}
// The EntityManagerFactory may not be discoverable by type when this condition // The EntityManagerFactory may not be discoverable by type when this condition
// is evaluated, so we need a well-known bean name. This is the one used by Spring // is evaluated, so we need a well-known bean name. This is the one used by Spring

View File

@ -19,7 +19,6 @@ package org.springframework.boot.autoconfigure.cache;
import net.sf.ehcache.Cache; import net.sf.ehcache.Cache;
import net.sf.ehcache.CacheManager; import net.sf.ehcache.CacheManager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ResourceCondition; import org.springframework.boot.autoconfigure.condition.ResourceCondition;
@ -45,11 +44,15 @@ import org.springframework.core.io.Resource;
EhCacheCacheConfiguration.ConfigAvailableCondition.class }) EhCacheCacheConfiguration.ConfigAvailableCondition.class })
class EhCacheCacheConfiguration { class EhCacheCacheConfiguration {
@Autowired private final CacheProperties cacheProperties;
private CacheProperties cacheProperties;
@Autowired private final CacheManagerCustomizers customizers;
private CacheManagerCustomizers customizers;
EhCacheCacheConfiguration(CacheProperties cacheProperties,
CacheManagerCustomizers customizers) {
this.cacheProperties = cacheProperties;
this.customizers = customizers;
}
@Bean @Bean
public EhCacheCacheManager cacheManager(CacheManager ehCacheCacheManager) { public EhCacheCacheManager cacheManager(CacheManager ehCacheCacheManager) {

View File

@ -18,7 +18,6 @@ package org.springframework.boot.autoconfigure.cache;
import java.util.Collection; import java.util.Collection;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.cache.Cache; import org.springframework.cache.Cache;
@ -41,8 +40,11 @@ import org.springframework.context.annotation.Configuration;
@Conditional(CacheCondition.class) @Conditional(CacheCondition.class)
class GenericCacheConfiguration { class GenericCacheConfiguration {
@Autowired private final CacheManagerCustomizers customizers;
private CacheManagerCustomizers customizers;
GenericCacheConfiguration(CacheManagerCustomizers customizers) {
this.customizers = customizers;
}
@Bean @Bean
public SimpleCacheManager cacheManager(Collection<Cache> caches) { public SimpleCacheManager cacheManager(Collection<Cache> caches) {

View File

@ -23,7 +23,6 @@ import com.hazelcast.core.Hazelcast;
import com.hazelcast.core.HazelcastInstance; import com.hazelcast.core.HazelcastInstance;
import com.hazelcast.spring.cache.HazelcastCacheManager; import com.hazelcast.spring.cache.HazelcastCacheManager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnSingleCandidate; import org.springframework.boot.autoconfigure.condition.ConditionalOnSingleCandidate;
import org.springframework.boot.autoconfigure.hazelcast.HazelcastConfigResourceCondition; import org.springframework.boot.autoconfigure.hazelcast.HazelcastConfigResourceCondition;
@ -45,11 +44,14 @@ abstract class HazelcastInstanceConfiguration {
@ConditionalOnSingleCandidate(HazelcastInstance.class) @ConditionalOnSingleCandidate(HazelcastInstance.class)
static class Existing { static class Existing {
@Autowired private final CacheProperties cacheProperties;
private CacheProperties cacheProperties;
@Autowired private final CacheManagerCustomizers customizers;
private CacheManagerCustomizers customizers;
Existing(CacheProperties cacheProperties, CacheManagerCustomizers customizers) {
this.cacheProperties = cacheProperties;
this.customizers = customizers;
}
@Bean @Bean
public HazelcastCacheManager cacheManager( public HazelcastCacheManager cacheManager(
@ -72,11 +74,14 @@ abstract class HazelcastInstanceConfiguration {
@Conditional(ConfigAvailableCondition.class) @Conditional(ConfigAvailableCondition.class)
static class Specific { static class Specific {
@Autowired private final CacheProperties cacheProperties;
private CacheProperties cacheProperties;
@Autowired private final CacheManagerCustomizers customizers;
private CacheManagerCustomizers customizers;
Specific(CacheProperties cacheProperties, CacheManagerCustomizers customizers) {
this.cacheProperties = cacheProperties;
this.customizers = customizers;
}
@Bean @Bean
public HazelcastInstance hazelcastInstance() throws IOException { public HazelcastInstance hazelcastInstance() throws IOException {

View File

@ -18,7 +18,6 @@ package org.springframework.boot.autoconfigure.cache;
import java.util.List; import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.AutoConfigureAfter; import org.springframework.boot.autoconfigure.AutoConfigureAfter;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
@ -43,11 +42,15 @@ import org.springframework.data.redis.core.RedisTemplate;
@Conditional(CacheCondition.class) @Conditional(CacheCondition.class)
class RedisCacheConfiguration { class RedisCacheConfiguration {
@Autowired private final CacheProperties cacheProperties;
private CacheProperties cacheProperties;
@Autowired private final CacheManagerCustomizers customizerInvoker;
private CacheManagerCustomizers customizerInvoker;
RedisCacheConfiguration(CacheProperties cacheProperties,
CacheManagerCustomizers customizerInvoker) {
this.cacheProperties = cacheProperties;
this.customizerInvoker = customizerInvoker;
}
@Bean @Bean
public RedisCacheManager cacheManager(RedisTemplate<Object, Object> redisTemplate) { public RedisCacheManager cacheManager(RedisTemplate<Object, Object> redisTemplate) {

View File

@ -18,7 +18,6 @@ package org.springframework.boot.autoconfigure.cache;
import java.util.List; import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.cache.CacheManager; import org.springframework.cache.CacheManager;
import org.springframework.cache.concurrent.ConcurrentMapCacheManager; import org.springframework.cache.concurrent.ConcurrentMapCacheManager;
@ -37,11 +36,15 @@ import org.springframework.context.annotation.Configuration;
@Conditional(CacheCondition.class) @Conditional(CacheCondition.class)
class SimpleCacheConfiguration { class SimpleCacheConfiguration {
@Autowired private final CacheProperties cacheProperties;
private CacheProperties cacheProperties;
@Autowired private final CacheManagerCustomizers customizerInvoker;
private CacheManagerCustomizers customizerInvoker;
SimpleCacheConfiguration(CacheProperties cacheProperties,
CacheManagerCustomizers customizerInvoker) {
this.cacheProperties = cacheProperties;
this.customizerInvoker = customizerInvoker;
}
@Bean @Bean
public ConcurrentMapCacheManager cacheManager() { public ConcurrentMapCacheManager cacheManager() {

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2015 the original author or authors. * Copyright 2012-2016 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -24,7 +24,6 @@ import com.datastax.driver.core.policies.ReconnectionPolicy;
import com.datastax.driver.core.policies.RetryPolicy; import com.datastax.driver.core.policies.RetryPolicy;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
@ -45,8 +44,11 @@ import org.springframework.util.StringUtils;
@EnableConfigurationProperties(CassandraProperties.class) @EnableConfigurationProperties(CassandraProperties.class)
public class CassandraAutoConfiguration { public class CassandraAutoConfiguration {
@Autowired private final CassandraProperties properties;
private CassandraProperties properties;
public CassandraAutoConfiguration(CassandraProperties properties) {
this.properties = properties;
}
@Bean @Bean
@ConditionalOnMissingBean @ConditionalOnMissingBean

View File

@ -22,7 +22,6 @@ import javax.validation.Validator;
import com.couchbase.client.java.CouchbaseBucket; import com.couchbase.client.java.CouchbaseBucket;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.condition.AnyNestedCondition; import org.springframework.boot.autoconfigure.condition.AnyNestedCondition;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
@ -62,8 +61,11 @@ public class CouchbaseAutoConfiguration {
@ConditionalOnMissingBean(AbstractCouchbaseConfiguration.class) @ConditionalOnMissingBean(AbstractCouchbaseConfiguration.class)
public static class CouchbaseConfiguration extends AbstractCouchbaseConfiguration { public static class CouchbaseConfiguration extends AbstractCouchbaseConfiguration {
@Autowired private final CouchbaseProperties properties;
private CouchbaseProperties properties;
public CouchbaseConfiguration(CouchbaseProperties properties) {
this.properties = properties;
}
@Override @Override
protected List<String> getBootstrapHosts() { protected List<String> getBootstrapHosts() {

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2015 the original author or authors. * Copyright 2012-2016 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -19,7 +19,6 @@ package org.springframework.boot.autoconfigure.data.cassandra;
import com.datastax.driver.core.Cluster; import com.datastax.driver.core.Cluster;
import com.datastax.driver.core.Session; import com.datastax.driver.core.Session;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.AutoConfigureAfter; import org.springframework.boot.autoconfigure.AutoConfigureAfter;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.cassandra.CassandraAutoConfiguration; import org.springframework.boot.autoconfigure.cassandra.CassandraAutoConfiguration;
@ -51,11 +50,15 @@ import org.springframework.data.cassandra.mapping.CassandraMappingContext;
@AutoConfigureAfter(CassandraAutoConfiguration.class) @AutoConfigureAfter(CassandraAutoConfiguration.class)
public class CassandraDataAutoConfiguration { public class CassandraDataAutoConfiguration {
@Autowired private final CassandraProperties properties;
private CassandraProperties properties;
@Autowired private final Cluster cluster;
private Cluster cluster;
public CassandraDataAutoConfiguration(CassandraProperties properties,
Cluster cluster) {
this.properties = properties;
this.cluster = cluster;
}
@Bean @Bean
@ConditionalOnMissingBean @ConditionalOnMissingBean

View File

@ -31,7 +31,6 @@ import org.elasticsearch.node.Node;
import org.elasticsearch.node.NodeBuilder; import org.elasticsearch.node.NodeBuilder;
import org.springframework.beans.factory.DisposableBean; import org.springframework.beans.factory.DisposableBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.boot.context.properties.EnableConfigurationProperties;
@ -69,11 +68,14 @@ public class ElasticsearchAutoConfiguration implements DisposableBean {
private static final Log logger = LogFactory private static final Log logger = LogFactory
.getLog(ElasticsearchAutoConfiguration.class); .getLog(ElasticsearchAutoConfiguration.class);
@Autowired private final ElasticsearchProperties properties;
private ElasticsearchProperties properties;
private Releasable releasable; private Releasable releasable;
public ElasticsearchAutoConfiguration(ElasticsearchProperties properties) {
this.properties = properties;
}
@Bean @Bean
@ConditionalOnMissingBean @ConditionalOnMissingBean
public Client elasticsearchClient() { public Client elasticsearchClient() {

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2015 the original author or authors. * Copyright 2012-2016 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -30,7 +30,6 @@ import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.BeanClassLoaderAware; import org.springframework.beans.factory.BeanClassLoaderAware;
import org.springframework.beans.factory.BeanFactory; import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.NoSuchBeanDefinitionException; import org.springframework.beans.factory.NoSuchBeanDefinitionException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.config.BeanDefinition; import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.boot.autoconfigure.AutoConfigurationPackages; import org.springframework.boot.autoconfigure.AutoConfigurationPackages;
import org.springframework.boot.autoconfigure.AutoConfigureAfter; import org.springframework.boot.autoconfigure.AutoConfigureAfter;
@ -87,17 +86,21 @@ import org.springframework.util.StringUtils;
@AutoConfigureAfter(MongoAutoConfiguration.class) @AutoConfigureAfter(MongoAutoConfiguration.class)
public class MongoDataAutoConfiguration implements BeanClassLoaderAware { public class MongoDataAutoConfiguration implements BeanClassLoaderAware {
@Autowired private final MongoProperties properties;
private MongoProperties properties;
@Autowired private final Environment environment;
private Environment environment;
@Autowired private final ResourceLoader resourceLoader;
private ResourceLoader resourceLoader;
private ClassLoader classLoader; private ClassLoader classLoader;
public MongoDataAutoConfiguration(MongoProperties properties, Environment environment,
ResourceLoader resourceLoader) {
this.properties = properties;
this.environment = environment;
this.resourceLoader = resourceLoader;
}
@Override @Override
public void setBeanClassLoader(ClassLoader classLoader) { public void setBeanClassLoader(ClassLoader classLoader) {
this.classLoader = classLoader; this.classLoader = classLoader;

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2015 the original author or authors. * Copyright 2012-2016 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -16,7 +16,6 @@
package org.springframework.boot.autoconfigure.data.rest; package org.springframework.boot.autoconfigure.data.rest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.data.rest.core.config.RepositoryRestConfiguration; import org.springframework.data.rest.core.config.RepositoryRestConfiguration;
@ -33,8 +32,11 @@ import org.springframework.data.rest.webmvc.config.RepositoryRestMvcConfiguratio
@Configuration @Configuration
class SpringBootRepositoryRestMvcConfiguration extends RepositoryRestMvcConfiguration { class SpringBootRepositoryRestMvcConfiguration extends RepositoryRestMvcConfiguration {
@Autowired private final RepositoryRestProperties properties;
private RepositoryRestProperties properties;
SpringBootRepositoryRestMvcConfiguration(RepositoryRestProperties properties) {
this.properties = properties;
}
@Bean @Bean
@Override @Override

View File

@ -66,11 +66,15 @@ public class FreeMarkerAutoConfiguration {
private static final Log logger = LogFactory private static final Log logger = LogFactory
.getLog(FreeMarkerAutoConfiguration.class); .getLog(FreeMarkerAutoConfiguration.class);
@Autowired private final ApplicationContext applicationContext;
private ApplicationContext applicationContext;
@Autowired private final FreeMarkerProperties properties;
private FreeMarkerProperties properties;
public FreeMarkerAutoConfiguration(ApplicationContext applicationContext,
FreeMarkerProperties properties) {
this.applicationContext = applicationContext;
this.properties = properties;
}
@PostConstruct @PostConstruct
public void checkTemplateLocationExists() { public void checkTemplateLocationExists() {

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2015 the original author or authors. * Copyright 2012-2016 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -137,8 +137,11 @@ public class GroovyTemplateAutoConfiguration {
@ConditionalOnProperty(name = "spring.groovy.template.enabled", matchIfMissing = true) @ConditionalOnProperty(name = "spring.groovy.template.enabled", matchIfMissing = true)
public static class GroovyWebConfiguration { public static class GroovyWebConfiguration {
@Autowired private final GroovyTemplateProperties properties;
private GroovyTemplateProperties properties;
public GroovyWebConfiguration(GroovyTemplateProperties properties) {
this.properties = properties;
}
@Bean @Bean
@ConditionalOnMissingBean(name = "groovyMarkupViewResolver") @ConditionalOnMissingBean(name = "groovyMarkupViewResolver")

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2015 the original author or authors. * Copyright 2012-2016 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -51,8 +51,11 @@ import org.springframework.security.config.annotation.web.configuration.WebSecur
@AutoConfigureAfter(SecurityAutoConfiguration.class) @AutoConfigureAfter(SecurityAutoConfiguration.class)
public class H2ConsoleAutoConfiguration { public class H2ConsoleAutoConfiguration {
@Autowired private final H2ConsoleProperties properties;
private H2ConsoleProperties properties;
public H2ConsoleAutoConfiguration(H2ConsoleProperties properties) {
this.properties = properties;
}
@Bean @Bean
public ServletRegistrationBean h2Console() { public ServletRegistrationBean h2Console() {

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2015 the original author or authors. * Copyright 2012-2016 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -22,7 +22,6 @@ import com.hazelcast.config.Config;
import com.hazelcast.core.Hazelcast; import com.hazelcast.core.Hazelcast;
import com.hazelcast.core.HazelcastInstance; import com.hazelcast.core.HazelcastInstance;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
@ -53,8 +52,11 @@ public class HazelcastAutoConfiguration {
@Conditional(ConfigAvailableCondition.class) @Conditional(ConfigAvailableCondition.class)
static class HazelcastConfigFileConfiguration { static class HazelcastConfigFileConfiguration {
@Autowired private final HazelcastProperties hazelcastProperties;
private HazelcastProperties hazelcastProperties;
HazelcastConfigFileConfiguration(HazelcastProperties hazelcastProperties) {
this.hazelcastProperties = hazelcastProperties;
}
@Bean @Bean
public HazelcastInstance hazelcastInstance() throws IOException { public HazelcastInstance hazelcastInstance() throws IOException {

View File

@ -41,7 +41,6 @@ import org.joda.time.format.DateTimeFormat;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.BeanFactoryUtils; import org.springframework.beans.factory.BeanFactoryUtils;
import org.springframework.beans.factory.ListableBeanFactory; import org.springframework.beans.factory.ListableBeanFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnJava; import org.springframework.boot.autoconfigure.condition.ConditionalOnJava;
import org.springframework.boot.autoconfigure.condition.ConditionalOnJava.JavaVersion; import org.springframework.boot.autoconfigure.condition.ConditionalOnJava.JavaVersion;
@ -97,8 +96,11 @@ public class JacksonAutoConfiguration {
private static final Log logger = LogFactory private static final Log logger = LogFactory
.getLog(JodaDateTimeJacksonConfiguration.class); .getLog(JodaDateTimeJacksonConfiguration.class);
@Autowired private final JacksonProperties jacksonProperties;
private JacksonProperties jacksonProperties;
JodaDateTimeJacksonConfiguration(JacksonProperties jacksonProperties) {
this.jacksonProperties = jacksonProperties;
}
@Bean @Bean
public SimpleModule jodaDateTimeSerializationModule() { public SimpleModule jodaDateTimeSerializationModule() {
@ -155,11 +157,15 @@ public class JacksonAutoConfiguration {
@EnableConfigurationProperties(JacksonProperties.class) @EnableConfigurationProperties(JacksonProperties.class)
static class JacksonObjectMapperBuilderConfiguration { static class JacksonObjectMapperBuilderConfiguration {
@Autowired private final ApplicationContext applicationContext;
private ApplicationContext applicationContext;
@Autowired private final JacksonProperties jacksonProperties;
private JacksonProperties jacksonProperties;
JacksonObjectMapperBuilderConfiguration(ApplicationContext applicationContext,
JacksonProperties jacksonProperties) {
this.applicationContext = applicationContext;
this.jacksonProperties = jacksonProperties;
}
@Bean @Bean
@ConditionalOnMissingBean(Jackson2ObjectMapperBuilder.class) @ConditionalOnMissingBean(Jackson2ObjectMapperBuilder.class)

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2015 the original author or authors. * Copyright 2012-2016 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -19,7 +19,6 @@ package org.springframework.boot.autoconfigure.jdbc;
import javax.annotation.PreDestroy; import javax.annotation.PreDestroy;
import org.springframework.beans.factory.BeanClassLoaderAware; import org.springframework.beans.factory.BeanClassLoaderAware;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
@ -41,8 +40,11 @@ public class EmbeddedDataSourceConfiguration implements BeanClassLoaderAware {
private ClassLoader classLoader; private ClassLoader classLoader;
@Autowired private final DataSourceProperties properties;
private DataSourceProperties properties;
public EmbeddedDataSourceConfiguration(DataSourceProperties properties) {
this.properties = properties;
}
@Override @Override
public void setBeanClassLoader(ClassLoader classLoader) { public void setBeanClassLoader(ClassLoader classLoader) {

View File

@ -19,7 +19,6 @@ package org.springframework.boot.autoconfigure.jdbc;
import javax.sql.DataSource; import javax.sql.DataSource;
import org.springframework.beans.factory.NoSuchBeanDefinitionException; import org.springframework.beans.factory.NoSuchBeanDefinitionException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.AutoConfigureBefore; import org.springframework.boot.autoconfigure.AutoConfigureBefore;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
@ -50,8 +49,11 @@ import org.springframework.jmx.support.JmxUtils;
@EnableConfigurationProperties(DataSourceProperties.class) @EnableConfigurationProperties(DataSourceProperties.class)
public class JndiDataSourceAutoConfiguration { public class JndiDataSourceAutoConfiguration {
@Autowired private final ApplicationContext context;
private ApplicationContext context;
public JndiDataSourceAutoConfiguration(ApplicationContext context) {
this.context = context;
}
@Bean(destroyMethod = "") @Bean(destroyMethod = "")
@ConditionalOnMissingBean @ConditionalOnMissingBean

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2014 the original author or authors. * Copyright 2012-2016 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -21,7 +21,6 @@ import java.util.Arrays;
import javax.jms.ConnectionFactory; import javax.jms.ConnectionFactory;
import javax.naming.NamingException; import javax.naming.NamingException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.AutoConfigureBefore; import org.springframework.boot.autoconfigure.AutoConfigureBefore;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.condition.AnyNestedCondition; import org.springframework.boot.autoconfigure.condition.AnyNestedCondition;
@ -56,8 +55,11 @@ public class JndiConnectionFactoryAutoConfiguration {
private static String[] JNDI_LOCATIONS = { "java:/JmsXA", private static String[] JNDI_LOCATIONS = { "java:/JmsXA",
"java:/XAConnectionFactory" }; "java:/XAConnectionFactory" };
@Autowired private final JmsProperties properties;
private JmsProperties properties;
public JndiConnectionFactoryAutoConfiguration(JmsProperties properties) {
this.properties = properties;
}
@Bean @Bean
public ConnectionFactory connectionFactory() throws NamingException { public ConnectionFactory connectionFactory() throws NamingException {

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2015 the original author or authors. * Copyright 2012-2016 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -23,7 +23,6 @@ import javax.sql.DataSource;
import liquibase.integration.spring.SpringLiquibase; import liquibase.integration.spring.SpringLiquibase;
import liquibase.servicelocator.ServiceLocator; import liquibase.servicelocator.ServiceLocator;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.AutoConfigureAfter; import org.springframework.boot.autoconfigure.AutoConfigureAfter;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
@ -39,7 +38,6 @@ import org.springframework.boot.liquibase.CommonsLoggingLiquibaseLogger;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import; import org.springframework.context.annotation.Import;
import org.springframework.core.io.DefaultResourceLoader;
import org.springframework.core.io.Resource; import org.springframework.core.io.Resource;
import org.springframework.core.io.ResourceLoader; import org.springframework.core.io.ResourceLoader;
import org.springframework.orm.jpa.AbstractEntityManagerFactoryBean; import org.springframework.orm.jpa.AbstractEntityManagerFactoryBean;
@ -68,14 +66,18 @@ public class LiquibaseAutoConfiguration {
@Import(LiquibaseJpaDependencyConfiguration.class) @Import(LiquibaseJpaDependencyConfiguration.class)
public static class LiquibaseConfiguration { public static class LiquibaseConfiguration {
@Autowired private final LiquibaseProperties properties;
private LiquibaseProperties properties = new LiquibaseProperties();
@Autowired private final ResourceLoader resourceLoader;
private ResourceLoader resourceLoader = new DefaultResourceLoader();
@Autowired private final DataSource dataSource;
private DataSource dataSource;
public LiquibaseConfiguration(LiquibaseProperties properties,
ResourceLoader resourceLoader, DataSource dataSource) {
this.properties = properties;
this.resourceLoader = resourceLoader;
this.dataSource = dataSource;
}
@PostConstruct @PostConstruct
public void checkChangelogExists() { public void checkChangelogExists() {

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2015 the original author or authors. * Copyright 2012-2016 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -19,7 +19,6 @@ package org.springframework.boot.autoconfigure.mail;
import javax.mail.Session; import javax.mail.Session;
import javax.naming.NamingException; import javax.naming.NamingException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnJndi; import org.springframework.boot.autoconfigure.condition.ConditionalOnJndi;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
@ -40,8 +39,11 @@ import org.springframework.jndi.JndiLocatorDelegate;
@ConditionalOnJndi @ConditionalOnJndi
class JndiSessionConfiguration { class JndiSessionConfiguration {
@Autowired private final MailProperties properties;
private MailProperties properties;
JndiSessionConfiguration(MailProperties properties) {
this.properties = properties;
}
@Bean @Bean
@ConditionalOnMissingBean @ConditionalOnMissingBean

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2015 the original author or authors. * Copyright 2012-2016 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -19,7 +19,6 @@ package org.springframework.boot.autoconfigure.mail;
import javax.annotation.PostConstruct; import javax.annotation.PostConstruct;
import javax.mail.MessagingException; import javax.mail.MessagingException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.AutoConfigureAfter; import org.springframework.boot.autoconfigure.AutoConfigureAfter;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
@ -41,8 +40,11 @@ import org.springframework.mail.javamail.JavaMailSenderImpl;
@ConditionalOnSingleCandidate(JavaMailSenderImpl.class) @ConditionalOnSingleCandidate(JavaMailSenderImpl.class)
public class MailSenderValidatorAutoConfiguration { public class MailSenderValidatorAutoConfiguration {
@Autowired private final JavaMailSenderImpl mailSender;
private JavaMailSenderImpl mailSender;
public MailSenderValidatorAutoConfiguration(JavaMailSenderImpl mailSender) {
this.mailSender = mailSender;
}
@PostConstruct @PostConstruct
public void validateConnection() { public void validateConnection() {

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2015 the original author or authors. * Copyright 2012-2016 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -98,8 +98,12 @@ public class DeviceDelegatingViewResolverAutoConfiguration {
protected static class ThymeleafViewResolverViewResolverDelegateConfiguration protected static class ThymeleafViewResolverViewResolverDelegateConfiguration
extends AbstractDelegateConfiguration { extends AbstractDelegateConfiguration {
@Autowired private final ThymeleafViewResolver viewResolver;
private ThymeleafViewResolver viewResolver;
protected ThymeleafViewResolverViewResolverDelegateConfiguration(
ThymeleafViewResolver viewResolver) {
this.viewResolver = viewResolver;
}
@Bean @Bean
public LiteDeviceDelegatingViewResolver deviceDelegatingViewResolver() { public LiteDeviceDelegatingViewResolver deviceDelegatingViewResolver() {
@ -120,8 +124,12 @@ public class DeviceDelegatingViewResolverAutoConfiguration {
protected static class InternalResourceViewResolverDelegateConfiguration protected static class InternalResourceViewResolverDelegateConfiguration
extends AbstractDelegateConfiguration { extends AbstractDelegateConfiguration {
@Autowired private final InternalResourceViewResolver viewResolver;
private InternalResourceViewResolver viewResolver;
protected InternalResourceViewResolverDelegateConfiguration(
InternalResourceViewResolver viewResolver) {
this.viewResolver = viewResolver;
}
@Bean @Bean
public LiteDeviceDelegatingViewResolver deviceDelegatingViewResolver() { public LiteDeviceDelegatingViewResolver deviceDelegatingViewResolver() {

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2014 the original author or authors. * Copyright 2012-2016 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -18,7 +18,6 @@ package org.springframework.boot.autoconfigure.mobile;
import java.util.List; import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.AutoConfigureAfter; import org.springframework.boot.autoconfigure.AutoConfigureAfter;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
@ -45,26 +44,34 @@ import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter
@ConditionalOnClass({ DeviceResolverHandlerInterceptor.class, @ConditionalOnClass({ DeviceResolverHandlerInterceptor.class,
DeviceHandlerMethodArgumentResolver.class }) DeviceHandlerMethodArgumentResolver.class })
@AutoConfigureAfter(WebMvcAutoConfiguration.class) @AutoConfigureAfter(WebMvcAutoConfiguration.class)
@ConditionalOnWebApplication
public class DeviceResolverAutoConfiguration { public class DeviceResolverAutoConfiguration {
@Bean
@ConditionalOnMissingBean(DeviceResolverHandlerInterceptor.class)
public DeviceResolverHandlerInterceptor deviceResolverHandlerInterceptor() {
return new DeviceResolverHandlerInterceptor();
}
@Bean
public DeviceHandlerMethodArgumentResolver deviceHandlerMethodArgumentResolver() {
return new DeviceHandlerMethodArgumentResolver();
}
@Configuration @Configuration
@ConditionalOnWebApplication
@Order(0) @Order(0)
protected static class DeviceResolverMvcConfiguration protected static class DeviceResolverMvcConfiguration
extends WebMvcConfigurerAdapter { extends WebMvcConfigurerAdapter {
@Autowired
private DeviceResolverHandlerInterceptor deviceResolverHandlerInterceptor; private DeviceResolverHandlerInterceptor deviceResolverHandlerInterceptor;
@Bean private DeviceHandlerMethodArgumentResolver deviceHandlerMethodArgumentResolver;
@ConditionalOnMissingBean(DeviceResolverHandlerInterceptor.class)
public DeviceResolverHandlerInterceptor deviceResolverHandlerInterceptor() {
return new DeviceResolverHandlerInterceptor();
}
@Bean protected DeviceResolverMvcConfiguration(
public DeviceHandlerMethodArgumentResolver deviceHandlerMethodArgumentResolver() { DeviceResolverHandlerInterceptor deviceResolverHandlerInterceptor,
return new DeviceHandlerMethodArgumentResolver(); DeviceHandlerMethodArgumentResolver deviceHandlerMethodArgumentResolver) {
this.deviceResolverHandlerInterceptor = deviceResolverHandlerInterceptor;
this.deviceHandlerMethodArgumentResolver = deviceHandlerMethodArgumentResolver;
} }
@Override @Override
@ -75,7 +82,7 @@ public class DeviceResolverAutoConfiguration {
@Override @Override
public void addArgumentResolvers( public void addArgumentResolvers(
List<HandlerMethodArgumentResolver> argumentResolvers) { List<HandlerMethodArgumentResolver> argumentResolvers) {
argumentResolvers.add(deviceHandlerMethodArgumentResolver()); argumentResolvers.add(this.deviceHandlerMethodArgumentResolver);
} }
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2014 the original author or authors. * Copyright 2012-2016 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -18,7 +18,6 @@ package org.springframework.boot.autoconfigure.mobile;
import java.util.List; import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.AutoConfigureAfter; import org.springframework.boot.autoconfigure.AutoConfigureAfter;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
@ -48,25 +47,33 @@ import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter
SitePreferenceHandlerMethodArgumentResolver.class }) SitePreferenceHandlerMethodArgumentResolver.class })
@AutoConfigureAfter(DeviceResolverAutoConfiguration.class) @AutoConfigureAfter(DeviceResolverAutoConfiguration.class)
@ConditionalOnProperty(prefix = "spring.mobile.sitepreference", name = "enabled", havingValue = "true", matchIfMissing = true) @ConditionalOnProperty(prefix = "spring.mobile.sitepreference", name = "enabled", havingValue = "true", matchIfMissing = true)
@ConditionalOnWebApplication
public class SitePreferenceAutoConfiguration { public class SitePreferenceAutoConfiguration {
@Bean
@ConditionalOnMissingBean(SitePreferenceHandlerInterceptor.class)
public SitePreferenceHandlerInterceptor sitePreferenceHandlerInterceptor() {
return new SitePreferenceHandlerInterceptor();
}
@Bean
public SitePreferenceHandlerMethodArgumentResolver sitePreferenceHandlerMethodArgumentResolver() {
return new SitePreferenceHandlerMethodArgumentResolver();
}
@Configuration @Configuration
@ConditionalOnWebApplication
protected static class SitePreferenceMvcConfiguration protected static class SitePreferenceMvcConfiguration
extends WebMvcConfigurerAdapter { extends WebMvcConfigurerAdapter {
@Autowired private final SitePreferenceHandlerInterceptor sitePreferenceHandlerInterceptor;
private SitePreferenceHandlerInterceptor sitePreferenceHandlerInterceptor;
@Bean private final SitePreferenceHandlerMethodArgumentResolver sitePreferenceHandlerMethodArgumentResolver;
@ConditionalOnMissingBean(SitePreferenceHandlerInterceptor.class)
public SitePreferenceHandlerInterceptor sitePreferenceHandlerInterceptor() {
return new SitePreferenceHandlerInterceptor();
}
@Bean protected SitePreferenceMvcConfiguration(
public SitePreferenceHandlerMethodArgumentResolver sitePreferenceHandlerMethodArgumentResolver() { SitePreferenceHandlerInterceptor sitePreferenceHandlerInterceptor,
return new SitePreferenceHandlerMethodArgumentResolver(); org.springframework.mobile.device.site.SitePreferenceHandlerMethodArgumentResolver sitePreferenceHandlerMethodArgumentResolver) {
this.sitePreferenceHandlerInterceptor = sitePreferenceHandlerInterceptor;
this.sitePreferenceHandlerMethodArgumentResolver = sitePreferenceHandlerMethodArgumentResolver;
} }
@Override @Override
@ -77,7 +84,7 @@ public class SitePreferenceAutoConfiguration {
@Override @Override
public void addArgumentResolvers( public void addArgumentResolvers(
List<HandlerMethodArgumentResolver> argumentResolvers) { List<HandlerMethodArgumentResolver> argumentResolvers) {
argumentResolvers.add(sitePreferenceHandlerMethodArgumentResolver()); argumentResolvers.add(this.sitePreferenceHandlerMethodArgumentResolver);
} }
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2015 the original author or authors. * Copyright 2012-2016 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -25,7 +25,6 @@ import com.samskivert.mustache.Mustache.TemplateLoader;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
@ -52,14 +51,18 @@ public class MustacheAutoConfiguration {
private static final Log logger = LogFactory.getLog(MustacheAutoConfiguration.class); private static final Log logger = LogFactory.getLog(MustacheAutoConfiguration.class);
@Autowired private final MustacheProperties mustache;
private MustacheProperties mustache;
@Autowired private final Environment environment;
private Environment environment;
@Autowired private final ApplicationContext applicationContext;
private ApplicationContext applicationContext;
public MustacheAutoConfiguration(MustacheProperties mustache, Environment environment,
ApplicationContext applicationContext) {
this.mustache = mustache;
this.environment = environment;
this.applicationContext = applicationContext;
}
@PostConstruct @PostConstruct
public void checkTemplateLocationExists() { public void checkTemplateLocationExists() {
@ -100,8 +103,11 @@ public class MustacheAutoConfiguration {
@ConditionalOnWebApplication @ConditionalOnWebApplication
protected static class MustacheWebConfiguration { protected static class MustacheWebConfiguration {
@Autowired private final MustacheProperties mustache;
private MustacheProperties mustache;
protected MustacheWebConfiguration(MustacheProperties mustache) {
this.mustache = mustache;
}
@Bean @Bean
@ConditionalOnMissingBean(MustacheViewResolver.class) @ConditionalOnMissingBean(MustacheViewResolver.class)

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2015 the original author or authors. * Copyright 2012-2016 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -25,7 +25,6 @@ import javax.sql.DataSource;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.AutoConfigureAfter; import org.springframework.boot.autoconfigure.AutoConfigureAfter;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.condition.ConditionOutcome; import org.springframework.boot.autoconfigure.condition.ConditionOutcome;
@ -82,11 +81,15 @@ public class HibernateJpaAutoConfiguration extends JpaBaseConfiguration {
"org.hibernate.engine.transaction.jta.platform.internal.WebSphereExtendedJtaPlatform", "org.hibernate.engine.transaction.jta.platform.internal.WebSphereExtendedJtaPlatform",
"org.hibernate.service.jta.platform.internal.WebSphereExtendedJtaPlatform", }; "org.hibernate.service.jta.platform.internal.WebSphereExtendedJtaPlatform", };
@Autowired private final JpaProperties properties;
private JpaProperties properties;
@Autowired private final DataSource dataSource;
private DataSource dataSource;
public HibernateJpaAutoConfiguration(JpaProperties properties,
DataSource dataSource) {
this.properties = properties;
this.dataSource = dataSource;
}
@Override @Override
protected AbstractJpaVendorAdapter createJpaVendorAdapter() { protected AbstractJpaVendorAdapter createJpaVendorAdapter() {

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2015 the original author or authors. * Copyright 2012-2016 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -191,9 +191,12 @@ public class SpringBootWebSecurityConfiguration {
protected static class ApplicationWebSecurityConfigurerAdapter protected static class ApplicationWebSecurityConfigurerAdapter
extends WebSecurityConfigurerAdapter { extends WebSecurityConfigurerAdapter {
@Autowired
private SecurityProperties security; private SecurityProperties security;
protected ApplicationWebSecurityConfigurerAdapter(SecurityProperties security) {
this.security = security;
}
@Override @Override
protected void configure(HttpSecurity http) throws Exception { protected void configure(HttpSecurity http) throws Exception {
if (this.security.isRequireSsl()) { if (this.security.isRequireSsl()) {

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2015 the original author or authors. * Copyright 2012-2016 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -16,7 +16,6 @@
package org.springframework.boot.autoconfigure.security.oauth2; package org.springframework.boot.autoconfigure.security.oauth2;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.AutoConfigureBefore; import org.springframework.boot.autoconfigure.AutoConfigureBefore;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
@ -49,8 +48,11 @@ import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter
@EnableConfigurationProperties(OAuth2ClientProperties.class) @EnableConfigurationProperties(OAuth2ClientProperties.class)
public class OAuth2AutoConfiguration { public class OAuth2AutoConfiguration {
@Autowired private final OAuth2ClientProperties credentials;
private OAuth2ClientProperties credentials;
public OAuth2AutoConfiguration(OAuth2ClientProperties credentials) {
this.credentials = credentials;
}
@Bean @Bean
public ResourceServerProperties resourceServerProperties() { public ResourceServerProperties resourceServerProperties() {

View File

@ -139,8 +139,11 @@ public class OAuth2AuthorizationServerConfiguration
@Configuration @Configuration
protected static class ClientDetailsLogger { protected static class ClientDetailsLogger {
@Autowired private final OAuth2ClientProperties credentials;
private OAuth2ClientProperties credentials;
protected ClientDetailsLogger(OAuth2ClientProperties credentials) {
this.credentials = credentials;
}
@PostConstruct @PostConstruct
public void init() { public void init() {
@ -158,8 +161,11 @@ public class OAuth2AuthorizationServerConfiguration
@ConditionalOnMissingBean(BaseClientDetails.class) @ConditionalOnMissingBean(BaseClientDetails.class)
protected static class BaseClientDetailsConfiguration { protected static class BaseClientDetailsConfiguration {
@Autowired private final OAuth2ClientProperties client;
private OAuth2ClientProperties client;
protected BaseClientDetailsConfiguration(OAuth2ClientProperties client) {
this.client = client;
}
@Bean @Bean
@ConfigurationProperties("security.oauth2.client") @ConfigurationProperties("security.oauth2.client")

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2015 the original author or authors. * Copyright 2012-2016 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -17,7 +17,6 @@
package org.springframework.boot.autoconfigure.security.oauth2.client; package org.springframework.boot.autoconfigure.security.oauth2.client;
import org.springframework.beans.factory.BeanFactory; import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionOutcome; import org.springframework.boot.autoconfigure.condition.ConditionOutcome;
import org.springframework.boot.autoconfigure.condition.SpringBootCondition; import org.springframework.boot.autoconfigure.condition.SpringBootCondition;
import org.springframework.boot.autoconfigure.security.SecurityProperties; import org.springframework.boot.autoconfigure.security.SecurityProperties;
@ -45,11 +44,15 @@ import org.springframework.util.ClassUtils;
public class OAuth2SsoDefaultConfiguration extends WebSecurityConfigurerAdapter public class OAuth2SsoDefaultConfiguration extends WebSecurityConfigurerAdapter
implements Ordered { implements Ordered {
@Autowired private final BeanFactory beanFactory;
BeanFactory beanFactory;
@Autowired private final OAuth2SsoProperties sso;
OAuth2SsoProperties sso;
public OAuth2SsoDefaultConfiguration(BeanFactory beanFactory,
OAuth2SsoProperties sso) {
this.beanFactory = beanFactory;
this.sso = sso;
}
@Override @Override
protected void configure(HttpSecurity http) throws Exception { protected void configure(HttpSecurity http) throws Exception {

View File

@ -17,7 +17,6 @@
package org.springframework.boot.autoconfigure.security.oauth2.resource; package org.springframework.boot.autoconfigure.security.oauth2.resource;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionOutcome; import org.springframework.boot.autoconfigure.condition.ConditionOutcome;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
@ -64,8 +63,11 @@ import org.springframework.util.StringUtils;
@Import(ResourceServerTokenServicesConfiguration.class) @Import(ResourceServerTokenServicesConfiguration.class)
public class OAuth2ResourceServerConfiguration { public class OAuth2ResourceServerConfiguration {
@Autowired private final ResourceServerProperties resource;
private ResourceServerProperties resource;
public OAuth2ResourceServerConfiguration(ResourceServerProperties resource) {
this.resource = resource;
}
@Bean @Bean
@ConditionalOnMissingBean(ResourceServerConfigurer.class) @ConditionalOnMissingBean(ResourceServerConfigurer.class)

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2015 the original author or authors. * Copyright 2012-2016 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -142,8 +142,11 @@ public class ResourceServerTokenServicesConfiguration {
@Conditional(TokenInfoCondition.class) @Conditional(TokenInfoCondition.class)
protected static class TokenInfoServicesConfiguration { protected static class TokenInfoServicesConfiguration {
@Autowired private final ResourceServerProperties resource;
private ResourceServerProperties resource;
protected TokenInfoServicesConfiguration(ResourceServerProperties resource) {
this.resource = resource;
}
@Bean @Bean
public RemoteTokenServices remoteTokenServices() { public RemoteTokenServices remoteTokenServices() {

View File

@ -20,7 +20,6 @@ import com.sendgrid.SendGrid;
import org.apache.http.HttpHost; import org.apache.http.HttpHost;
import org.apache.http.impl.client.HttpClientBuilder; import org.apache.http.impl.client.HttpClientBuilder;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.condition.AnyNestedCondition; import org.springframework.boot.autoconfigure.condition.AnyNestedCondition;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
@ -44,8 +43,11 @@ import org.springframework.context.annotation.Configuration;
@EnableConfigurationProperties(SendGridProperties.class) @EnableConfigurationProperties(SendGridProperties.class)
public class SendGridAutoConfiguration { public class SendGridAutoConfiguration {
@Autowired private final SendGridProperties properties;
private SendGridProperties properties;
public SendGridAutoConfiguration(SendGridProperties properties) {
this.properties = properties;
}
@Bean @Bean
@ConditionalOnMissingBean(SendGrid.class) @ConditionalOnMissingBean(SendGrid.class)

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2015 the original author or authors. * Copyright 2012-2016 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -16,9 +16,6 @@
package org.springframework.boot.autoconfigure.session; package org.springframework.boot.autoconfigure.session;
import javax.annotation.PostConstruct;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.AutoConfigureAfter; import org.springframework.boot.autoconfigure.AutoConfigureAfter;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
@ -55,14 +52,18 @@ public class SessionAutoConfiguration {
@Configuration @Configuration
public static class SessionRedisHttpConfiguration { public static class SessionRedisHttpConfiguration {
@Autowired private final ServerProperties serverProperties;
private ServerProperties serverProperties;
@Autowired private final RedisOperationsSessionRepository sessionRepository;
private RedisOperationsSessionRepository sessionRepository;
@PostConstruct public SessionRedisHttpConfiguration(ServerProperties serverProperties,
public void applyConfigurationProperties() { RedisOperationsSessionRepository sessionRepository) {
this.serverProperties = serverProperties;
this.sessionRepository = sessionRepository;
applyConfigurationProperties();
}
private void applyConfigurationProperties() {
Integer timeout = this.serverProperties.getSession().getTimeout(); Integer timeout = this.serverProperties.getSession().getTimeout();
if (timeout != null) { if (timeout != null) {
this.sessionRepository.setDefaultMaxInactiveInterval(timeout); this.sessionRepository.setDefaultMaxInactiveInterval(timeout);

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2015 the original author or authors. * Copyright 2012-2016 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -16,7 +16,6 @@
package org.springframework.boot.autoconfigure.social; package org.springframework.boot.autoconfigure.social;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.AutoConfigureAfter; import org.springframework.boot.autoconfigure.AutoConfigureAfter;
import org.springframework.boot.autoconfigure.AutoConfigureBefore; import org.springframework.boot.autoconfigure.AutoConfigureBefore;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
@ -59,8 +58,11 @@ public class FacebookAutoConfiguration {
@ConditionalOnWebApplication @ConditionalOnWebApplication
protected static class FacebookConfigurerAdapter extends SocialAutoConfigurerAdapter { protected static class FacebookConfigurerAdapter extends SocialAutoConfigurerAdapter {
@Autowired private final FacebookProperties properties;
private FacebookProperties properties;
protected FacebookConfigurerAdapter(FacebookProperties properties) {
this.properties = properties;
}
@Bean @Bean
@ConditionalOnMissingBean(Facebook.class) @ConditionalOnMissingBean(Facebook.class)

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2015 the original author or authors. * Copyright 2012-2016 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -16,7 +16,6 @@
package org.springframework.boot.autoconfigure.social; package org.springframework.boot.autoconfigure.social;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.AutoConfigureAfter; import org.springframework.boot.autoconfigure.AutoConfigureAfter;
import org.springframework.boot.autoconfigure.AutoConfigureBefore; import org.springframework.boot.autoconfigure.AutoConfigureBefore;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
@ -59,8 +58,11 @@ public class LinkedInAutoConfiguration {
@ConditionalOnWebApplication @ConditionalOnWebApplication
protected static class LinkedInConfigurerAdapter extends SocialAutoConfigurerAdapter { protected static class LinkedInConfigurerAdapter extends SocialAutoConfigurerAdapter {
@Autowired private final LinkedInProperties properties;
private LinkedInProperties properties;
protected LinkedInConfigurerAdapter(LinkedInProperties properties) {
this.properties = properties;
}
@Bean @Bean
@ConditionalOnMissingBean(LinkedIn.class) @ConditionalOnMissingBean(LinkedIn.class)

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2015 the original author or authors. * Copyright 2012-2016 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -16,7 +16,6 @@
package org.springframework.boot.autoconfigure.social; package org.springframework.boot.autoconfigure.social;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.AutoConfigureAfter; import org.springframework.boot.autoconfigure.AutoConfigureAfter;
import org.springframework.boot.autoconfigure.AutoConfigureBefore; import org.springframework.boot.autoconfigure.AutoConfigureBefore;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
@ -60,8 +59,11 @@ public class TwitterAutoConfiguration {
@ConditionalOnWebApplication @ConditionalOnWebApplication
protected static class TwitterConfigurerAdapter extends SocialAutoConfigurerAdapter { protected static class TwitterConfigurerAdapter extends SocialAutoConfigurerAdapter {
@Autowired private final TwitterProperties properties;
private TwitterProperties properties;
protected TwitterConfigurerAdapter(TwitterProperties properties) {
this.properties = properties;
}
@Bean @Bean
@ConditionalOnMissingBean @ConditionalOnMissingBean

View File

@ -24,7 +24,6 @@ import org.apache.solr.client.solrj.SolrClient;
import org.apache.solr.client.solrj.impl.CloudSolrClient; import org.apache.solr.client.solrj.impl.CloudSolrClient;
import org.apache.solr.client.solrj.impl.HttpSolrClient; import org.apache.solr.client.solrj.impl.HttpSolrClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
@ -44,11 +43,14 @@ import org.springframework.util.StringUtils;
@EnableConfigurationProperties(SolrProperties.class) @EnableConfigurationProperties(SolrProperties.class)
public class SolrAutoConfiguration { public class SolrAutoConfiguration {
@Autowired private final SolrProperties properties;
private SolrProperties properties;
private SolrClient solrClient; private SolrClient solrClient;
public SolrAutoConfiguration(SolrProperties properties) {
this.properties = properties;
}
@PreDestroy @PreDestroy
public void close() throws IOException { public void close() throws IOException {
if (this.solrClient != null) { if (this.solrClient != null) {

View File

@ -212,11 +212,15 @@ public class ThymeleafAutoConfiguration {
@ConditionalOnWebApplication @ConditionalOnWebApplication
protected static class ThymeleafViewResolverConfiguration { protected static class ThymeleafViewResolverConfiguration {
@Autowired private final ThymeleafProperties properties;
private ThymeleafProperties properties;
@Autowired private final SpringTemplateEngine templateEngine;
private SpringTemplateEngine templateEngine;
protected ThymeleafViewResolverConfiguration(ThymeleafProperties properties,
SpringTemplateEngine templateEngine) {
this.properties = properties;
this.templateEngine = templateEngine;
}
@Bean @Bean
@ConditionalOnMissingBean(name = "thymeleafViewResolver") @ConditionalOnMissingBean(name = "thymeleafViewResolver")

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2015 the original author or authors. * Copyright 2012-2016 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -16,7 +16,6 @@
package org.springframework.boot.autoconfigure.transaction; package org.springframework.boot.autoconfigure.transaction;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.AutoConfigureAfter; import org.springframework.boot.autoconfigure.AutoConfigureAfter;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
@ -43,8 +42,11 @@ import org.springframework.transaction.support.TransactionTemplate;
DataSourceTransactionManagerAutoConfiguration.class }) DataSourceTransactionManagerAutoConfiguration.class })
public class TransactionAutoConfiguration { public class TransactionAutoConfiguration {
@Autowired private final PlatformTransactionManager transactionManager;
private PlatformTransactionManager transactionManager;
public TransactionAutoConfiguration(PlatformTransactionManager transactionManager) {
this.transactionManager = transactionManager;
}
@Bean @Bean
@ConditionalOnMissingBean @ConditionalOnMissingBean

View File

@ -27,7 +27,6 @@ import com.atomikos.icatch.config.UserTransactionService;
import com.atomikos.icatch.config.UserTransactionServiceImp; import com.atomikos.icatch.config.UserTransactionServiceImp;
import com.atomikos.icatch.jta.UserTransactionManager; import com.atomikos.icatch.jta.UserTransactionManager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.ApplicationHome; import org.springframework.boot.ApplicationHome;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
@ -59,8 +58,11 @@ import org.springframework.util.StringUtils;
@ConditionalOnMissingBean(PlatformTransactionManager.class) @ConditionalOnMissingBean(PlatformTransactionManager.class)
class AtomikosJtaConfiguration { class AtomikosJtaConfiguration {
@Autowired private final JtaProperties jtaProperties;
private JtaProperties jtaProperties;
AtomikosJtaConfiguration(JtaProperties jtaProperties) {
this.jtaProperties = jtaProperties;
}
@Bean(initMethod = "init", destroyMethod = "shutdownForce") @Bean(initMethod = "init", destroyMethod = "shutdownForce")
@ConditionalOnMissingBean(UserTransactionService.class) @ConditionalOnMissingBean(UserTransactionService.class)

View File

@ -25,7 +25,6 @@ import bitronix.tm.BitronixTransactionManager;
import bitronix.tm.TransactionManagerServices; import bitronix.tm.TransactionManagerServices;
import bitronix.tm.jndi.BitronixContext; import bitronix.tm.jndi.BitronixContext;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.ApplicationHome; import org.springframework.boot.ApplicationHome;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
@ -54,8 +53,11 @@ import org.springframework.util.StringUtils;
@ConditionalOnMissingBean(PlatformTransactionManager.class) @ConditionalOnMissingBean(PlatformTransactionManager.class)
class BitronixJtaConfiguration { class BitronixJtaConfiguration {
@Autowired private final JtaProperties jtaProperties;
private JtaProperties jtaProperties;
BitronixJtaConfiguration(JtaProperties jtaProperties) {
this.jtaProperties = jtaProperties;
}
@Bean @Bean
@ConditionalOnMissingBean @ConditionalOnMissingBean

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2015 the original author or authors. * Copyright 2012-2016 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -64,11 +64,15 @@ public class VelocityAutoConfiguration {
private static final Log logger = LogFactory.getLog(VelocityAutoConfiguration.class); private static final Log logger = LogFactory.getLog(VelocityAutoConfiguration.class);
@Autowired private final ApplicationContext applicationContext;
private ApplicationContext applicationContext;
@Autowired private final VelocityProperties properties;
private VelocityProperties properties;
public VelocityAutoConfiguration(ApplicationContext applicationContext,
VelocityProperties properties) {
this.applicationContext = applicationContext;
this.properties = properties;
}
@PostConstruct @PostConstruct
public void checkTemplateLocationExists() { public void checkTemplateLocationExists() {

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2015 the original author or authors. * Copyright 2012-2016 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -27,7 +27,6 @@ import javax.servlet.http.HttpServletResponse;
import org.springframework.aop.framework.autoproxy.AutoProxyUtils; import org.springframework.aop.framework.autoproxy.AutoProxyUtils;
import org.springframework.beans.BeansException; import org.springframework.beans.BeansException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.config.BeanFactoryPostProcessor; import org.springframework.beans.factory.config.BeanFactoryPostProcessor;
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory; import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
import org.springframework.boot.autoconfigure.AutoConfigureBefore; import org.springframework.boot.autoconfigure.AutoConfigureBefore;
@ -77,8 +76,11 @@ import org.springframework.web.util.HtmlUtils;
@Configuration @Configuration
public class ErrorMvcAutoConfiguration { public class ErrorMvcAutoConfiguration {
@Autowired private final ServerProperties properties;
private ServerProperties properties;
public ErrorMvcAutoConfiguration(ServerProperties properties) {
this.properties = properties;
}
@Bean @Bean
@ConditionalOnMissingBean(value = ErrorAttributes.class, search = SearchStrategy.CURRENT) @ConditionalOnMissingBean(value = ErrorAttributes.class, search = SearchStrategy.CURRENT)

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2014 the original author or authors. * Copyright 2012-2016 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -16,7 +16,6 @@
package org.springframework.boot.autoconfigure.web; package org.springframework.boot.autoconfigure.web;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
@ -40,8 +39,11 @@ import org.springframework.web.filter.CharacterEncodingFilter;
@ConditionalOnProperty(prefix = "spring.http.encoding", value = "enabled", matchIfMissing = true) @ConditionalOnProperty(prefix = "spring.http.encoding", value = "enabled", matchIfMissing = true)
public class HttpEncodingAutoConfiguration { public class HttpEncodingAutoConfiguration {
@Autowired private final HttpEncodingProperties httpEncodingProperties;
private HttpEncodingProperties httpEncodingProperties;
public HttpEncodingAutoConfiguration(HttpEncodingProperties httpEncodingProperties) {
this.httpEncodingProperties = httpEncodingProperties;
}
@Bean @Bean
@ConditionalOnMissingBean(CharacterEncodingFilter.class) @ConditionalOnMissingBean(CharacterEncodingFilter.class)

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2015 the original author or authors. * Copyright 2012-2016 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -68,8 +68,12 @@ public class HttpMessageConvertersAutoConfiguration {
@EnableConfigurationProperties(HttpEncodingProperties.class) @EnableConfigurationProperties(HttpEncodingProperties.class)
protected static class StringHttpMessageConverterConfiguration { protected static class StringHttpMessageConverterConfiguration {
@Autowired private final HttpEncodingProperties encodingProperties;
private HttpEncodingProperties encodingProperties;
protected StringHttpMessageConverterConfiguration(
HttpEncodingProperties encodingProperties) {
this.encodingProperties = encodingProperties;
}
@Bean @Bean
@ConditionalOnMissingBean @ConditionalOnMissingBean

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2015 the original author or authors. * Copyright 2012-2016 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -19,7 +19,6 @@ package org.springframework.boot.autoconfigure.web;
import javax.servlet.MultipartConfigElement; import javax.servlet.MultipartConfigElement;
import javax.servlet.Servlet; import javax.servlet.Servlet;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
@ -52,8 +51,11 @@ import org.springframework.web.servlet.DispatcherServlet;
@EnableConfigurationProperties(MultipartProperties.class) @EnableConfigurationProperties(MultipartProperties.class)
public class MultipartAutoConfiguration { public class MultipartAutoConfiguration {
@Autowired private final MultipartProperties multipartProperties;
private MultipartProperties multipartProperties = new MultipartProperties();
public MultipartAutoConfiguration(MultipartProperties multipartProperties) {
this.multipartProperties = multipartProperties;
}
@Bean @Bean
@ConditionalOnMissingBean @ConditionalOnMissingBean

View File

@ -296,8 +296,11 @@ public class WebMvcAutoConfiguration {
@ConditionalOnProperty(value = "spring.mvc.favicon.enabled", matchIfMissing = true) @ConditionalOnProperty(value = "spring.mvc.favicon.enabled", matchIfMissing = true)
public static class FaviconConfiguration { public static class FaviconConfiguration {
@Autowired private final ResourceProperties resourceProperties;
private ResourceProperties resourceProperties = new ResourceProperties();
public FaviconConfiguration(ResourceProperties resourceProperties) {
this.resourceProperties = resourceProperties;
}
@Bean @Bean
public SimpleUrlHandlerMapping faviconHandlerMapping() { public SimpleUrlHandlerMapping faviconHandlerMapping() {

View File

@ -20,7 +20,6 @@ import java.util.List;
import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.AutoConfigureAfter; import org.springframework.boot.autoconfigure.AutoConfigureAfter;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
@ -58,8 +57,11 @@ public class WebSocketMessagingAutoConfiguration {
static class WebSocketMessageConverterConfiguration static class WebSocketMessageConverterConfiguration
extends AbstractWebSocketMessageBrokerConfigurer { extends AbstractWebSocketMessageBrokerConfigurer {
@Autowired private final ObjectMapper objectMapper;
private ObjectMapper objectMapper;
WebSocketMessageConverterConfiguration(ObjectMapper objectMapper) {
this.objectMapper = objectMapper;
}
@Override @Override
public void registerStompEndpoints(StompEndpointRegistry registry) { public void registerStompEndpoints(StompEndpointRegistry registry) {

View File

@ -36,6 +36,10 @@ import static org.mockito.Mockito.mock;
public class CouchbaseTestConfiguration public class CouchbaseTestConfiguration
extends CouchbaseAutoConfiguration.CouchbaseConfiguration { extends CouchbaseAutoConfiguration.CouchbaseConfiguration {
public CouchbaseTestConfiguration(CouchbaseProperties properties) {
super(properties);
}
@Override @Override
public Cluster couchbaseCluster() throws Exception { public Cluster couchbaseCluster() throws Exception {
return mock(CouchbaseCluster.class); return mock(CouchbaseCluster.class);

View File

@ -33,7 +33,6 @@ import org.junit.Test;
import org.junit.rules.ExpectedException; import org.junit.rules.ExpectedException;
import org.springframework.beans.factory.BeanCreationException; import org.springframework.beans.factory.BeanCreationException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfiguration; import org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfiguration;
import org.springframework.boot.autoconfigure.jdbc.DataSourceBuilder; import org.springframework.boot.autoconfigure.jdbc.DataSourceBuilder;
import org.springframework.boot.autoconfigure.jdbc.EmbeddedDataSourceConfiguration; import org.springframework.boot.autoconfigure.jdbc.EmbeddedDataSourceConfiguration;
@ -266,8 +265,11 @@ public class FlywayAutoConfigurationTests {
@Configuration @Configuration
protected static class CustomFlywayWithJpaConfiguration { protected static class CustomFlywayWithJpaConfiguration {
@Autowired private final DataSource dataSource;
private DataSource dataSource;
protected CustomFlywayWithJpaConfiguration(DataSource dataSource) {
this.dataSource = dataSource;
}
@Bean @Bean
public Flyway flyway() { public Flyway flyway() {

View File

@ -30,7 +30,6 @@ import org.junit.Test;
import org.junit.rules.ExpectedException; import org.junit.rules.ExpectedException;
import org.springframework.beans.factory.BeanCreationException; import org.springframework.beans.factory.BeanCreationException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfiguration; import org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfiguration;
import org.springframework.boot.autoconfigure.TestAutoConfigurationPackage; import org.springframework.boot.autoconfigure.TestAutoConfigurationPackage;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration; import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
@ -291,8 +290,11 @@ public abstract class AbstractJpaAutoConfigurationTests {
@TestAutoConfigurationPackage(AbstractJpaAutoConfigurationTests.class) @TestAutoConfigurationPackage(AbstractJpaAutoConfigurationTests.class)
public static class TestConfigurationWithCustomPersistenceUnitManager { public static class TestConfigurationWithCustomPersistenceUnitManager {
@Autowired private final DataSource dataSource;
private DataSource dataSource;
public TestConfigurationWithCustomPersistenceUnitManager(DataSource dataSource) {
this.dataSource = dataSource;
}
@Bean @Bean
public PersistenceUnitManager persistenceUnitManager() { public PersistenceUnitManager persistenceUnitManager() {

View File

@ -32,7 +32,6 @@ import org.springframework.beans.factory.BeanCreationException;
import org.springframework.boot.autoconfigure.flyway.FlywayAutoConfiguration; import org.springframework.boot.autoconfigure.flyway.FlywayAutoConfiguration;
import org.springframework.boot.autoconfigure.liquibase.LiquibaseAutoConfiguration; import org.springframework.boot.autoconfigure.liquibase.LiquibaseAutoConfiguration;
import org.springframework.boot.autoconfigure.transaction.jta.JtaAutoConfiguration; import org.springframework.boot.autoconfigure.transaction.jta.JtaAutoConfiguration;
import org.springframework.boot.autoconfigure.transaction.jta.JtaProperties;
import org.springframework.boot.orm.jpa.hibernate.SpringJtaPlatform; import org.springframework.boot.orm.jpa.hibernate.SpringJtaPlatform;
import org.springframework.boot.test.EnvironmentTestUtils; import org.springframework.boot.test.EnvironmentTestUtils;
import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.jdbc.core.JdbcTemplate;
@ -133,7 +132,7 @@ public class HibernateJpaAutoConfigurationTests
@Test @Test
public void defaultJtaPlatform() throws Exception { public void defaultJtaPlatform() throws Exception {
this.context.register(JtaProperties.class, JtaAutoConfiguration.class); this.context.register(JtaAutoConfiguration.class);
setupTestConfiguration(); setupTestConfiguration();
this.context.refresh(); this.context.refresh();
Map<String, Object> jpaPropertyMap = this.context Map<String, Object> jpaPropertyMap = this.context
@ -148,7 +147,7 @@ public class HibernateJpaAutoConfigurationTests
EnvironmentTestUtils.addEnvironment(this.context, EnvironmentTestUtils.addEnvironment(this.context,
"spring.jpa.properties.hibernate.transaction.jta.platform:" "spring.jpa.properties.hibernate.transaction.jta.platform:"
+ TestJtaPlatform.class.getName()); + TestJtaPlatform.class.getName());
this.context.register(JtaProperties.class, JtaAutoConfiguration.class); this.context.register(JtaAutoConfiguration.class);
setupTestConfiguration(); setupTestConfiguration();
this.context.refresh(); this.context.refresh();
Map<String, Object> jpaPropertyMap = this.context Map<String, Object> jpaPropertyMap = this.context

View File

@ -23,7 +23,6 @@ import javax.servlet.DispatcherType;
import org.junit.After; import org.junit.After;
import org.junit.Test; import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfiguration; import org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfiguration;
import org.springframework.boot.autoconfigure.TestAutoConfigurationPackage; import org.springframework.boot.autoconfigure.TestAutoConfigurationPackage;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration; import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
@ -442,8 +441,11 @@ public class SecurityAutoConfigurationTests {
@Configuration @Configuration
protected static class SecurityCustomizer extends WebSecurityConfigurerAdapter { protected static class SecurityCustomizer extends WebSecurityConfigurerAdapter {
@Autowired final AuthenticationManager authenticationManager;
AuthenticationManager authenticationManager;
protected SecurityCustomizer(AuthenticationManager authenticationManager) {
this.authenticationManager = authenticationManager;
}
} }
@ -451,12 +453,15 @@ public class SecurityAutoConfigurationTests {
protected static class WorkaroundSecurityCustomizer protected static class WorkaroundSecurityCustomizer
extends WebSecurityConfigurerAdapter { extends WebSecurityConfigurerAdapter {
@Autowired private final AuthenticationManagerBuilder builder;
private AuthenticationManagerBuilder builder;
@SuppressWarnings("unused") @SuppressWarnings("unused")
private AuthenticationManager authenticationManager; private AuthenticationManager authenticationManager;
protected WorkaroundSecurityCustomizer(AuthenticationManagerBuilder builder) {
this.builder = builder;
}
@Override @Override
protected void configure(HttpSecurity http) throws Exception { protected void configure(HttpSecurity http) throws Exception {
this.authenticationManager = new AuthenticationManager() { this.authenticationManager = new AuthenticationManager() {

View File

@ -245,6 +245,8 @@ public class SpringBootWebSecurityConfigurationTests {
protected static class TestInjectWebConfiguration protected static class TestInjectWebConfiguration
extends WebSecurityConfigurerAdapter { extends WebSecurityConfigurerAdapter {
private final AuthenticationManagerBuilder auth;
// It's a bad idea to inject an AuthenticationManager into a // It's a bad idea to inject an AuthenticationManager into a
// WebSecurityConfigurerAdapter because it can cascade early instantiation, // WebSecurityConfigurerAdapter because it can cascade early instantiation,
// unless you explicitly want the Boot default AuthenticationManager. It's // unless you explicitly want the Boot default AuthenticationManager. It's
@ -252,8 +254,9 @@ public class SpringBootWebSecurityConfigurationTests {
// might even be necessary to wrap the builder in a lazy AuthenticationManager // might even be necessary to wrap the builder in a lazy AuthenticationManager
// (that calls getOrBuild() only when the AuthenticationManager is actually // (that calls getOrBuild() only when the AuthenticationManager is actually
// called). // called).
@Autowired protected TestInjectWebConfiguration(AuthenticationManagerBuilder auth) {
private AuthenticationManagerBuilder auth; this.auth = auth;
}
@Override @Override
public void init(WebSecurity web) throws Exception { public void init(WebSecurity web) throws Exception {

View File

@ -469,8 +469,11 @@ public class OAuth2AutoConfigurationTests {
@EnableResourceServer @EnableResourceServer
protected static class CustomResourceServer extends ResourceServerConfigurerAdapter { protected static class CustomResourceServer extends ResourceServerConfigurerAdapter {
@Autowired private final ResourceServerProperties config;
private ResourceServerProperties config;
protected CustomResourceServer(ResourceServerProperties config) {
this.config = config;
}
@Override @Override
public void configure(ResourceServerSecurityConfigurer resources) public void configure(ResourceServerSecurityConfigurer resources)
@ -493,8 +496,11 @@ public class OAuth2AutoConfigurationTests {
protected static class CustomAuthorizationServer protected static class CustomAuthorizationServer
extends AuthorizationServerConfigurerAdapter { extends AuthorizationServerConfigurerAdapter {
@Autowired private final AuthenticationManager authenticationManager;
private AuthenticationManager authenticationManager;
protected CustomAuthorizationServer(AuthenticationManager authenticationManager) {
this.authenticationManager = authenticationManager;
}
@Bean @Bean
public TokenStore tokenStore() { public TokenStore tokenStore() {

View File

@ -23,7 +23,6 @@ import java.util.Map;
import org.junit.After; import org.junit.After;
import org.junit.Test; import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.config.BeanDefinition; import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.beans.factory.support.BeanDefinitionRegistry; import org.springframework.beans.factory.support.BeanDefinitionRegistry;
import org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfiguration; import org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfiguration;
@ -242,9 +241,12 @@ public class ResourceServerTokenServicesConfigurationTests {
@Configuration @Configuration
protected static class ResourceServerPropertiesConfiguration { protected static class ResourceServerPropertiesConfiguration {
@Autowired
private OAuth2ClientProperties credentials; private OAuth2ClientProperties credentials;
public ResourceServerPropertiesConfiguration(OAuth2ClientProperties credentials) {
this.credentials = credentials;
}
@Bean @Bean
public ResourceServerProperties resourceServerProperties() { public ResourceServerProperties resourceServerProperties() {
return new ResourceServerProperties(this.credentials.getClientId(), return new ResourceServerProperties(this.credentials.getClientId(),

View File

@ -16,7 +16,6 @@
package org.springframework.boot.autoconfigure.security.user; package org.springframework.boot.autoconfigure.security.user;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.orm.jpa.EntityScan; import org.springframework.boot.orm.jpa.EntityScan;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.data.jpa.repository.config.EnableJpaRepositories; import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
@ -30,8 +29,11 @@ import org.springframework.security.config.annotation.method.configuration.Enabl
@EnableJpaRepositories(basePackageClasses = User.class) @EnableJpaRepositories(basePackageClasses = User.class)
public class SecurityConfig extends GlobalAuthenticationConfigurerAdapter { public class SecurityConfig extends GlobalAuthenticationConfigurerAdapter {
@Autowired protected final UserRepository userRepository;
protected UserRepository userRepository;
public SecurityConfig(UserRepository userRepository) {
this.userRepository = userRepository;
}
@Override @Override
public void init(AuthenticationManagerBuilder auth) throws Exception { public void init(AuthenticationManagerBuilder auth) throws Exception {

View File

@ -124,8 +124,8 @@ public class WebSocketMessagingAutoConfigurationTests {
private List<MessageConverter> getCustomizedConverters() { private List<MessageConverter> getCustomizedConverters() {
List<MessageConverter> customizedConverters = new ArrayList<MessageConverter>(); List<MessageConverter> customizedConverters = new ArrayList<MessageConverter>();
WebSocketMessagingAutoConfiguration.WebSocketMessageConverterConfiguration configuration = new WebSocketMessagingAutoConfiguration.WebSocketMessageConverterConfiguration(); WebSocketMessagingAutoConfiguration.WebSocketMessageConverterConfiguration configuration = new WebSocketMessagingAutoConfiguration.WebSocketMessageConverterConfiguration(
ReflectionTestUtils.setField(configuration, "objectMapper", new ObjectMapper()); new ObjectMapper());
configuration.configureMessageConverters(customizedConverters); configuration.configureMessageConverters(customizedConverters);
return customizedConverters; return customizedConverters;
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2015 the original author or authors. * Copyright 2012-2016 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -74,11 +74,15 @@ public class RemoteDevToolsAutoConfiguration {
private static final Log logger = LogFactory private static final Log logger = LogFactory
.getLog(RemoteDevToolsAutoConfiguration.class); .getLog(RemoteDevToolsAutoConfiguration.class);
@Autowired private final DevToolsProperties properties;
private DevToolsProperties properties;
@Autowired private final ServerProperties serverProperties;
private ServerProperties serverProperties;
public RemoteDevToolsAutoConfiguration(DevToolsProperties properties,
ServerProperties serverProperties) {
this.properties = properties;
this.serverProperties = serverProperties;
}
@Bean @Bean
@ConditionalOnMissingBean @ConditionalOnMissingBean

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2015 the original author or authors. * Copyright 2012-2016 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -80,12 +80,15 @@ public class RemoteClientConfiguration {
private static final Log logger = LogFactory.getLog(RemoteClientConfiguration.class); private static final Log logger = LogFactory.getLog(RemoteClientConfiguration.class);
@Autowired private final DevToolsProperties properties;
private DevToolsProperties properties;
@Value("${remoteUrl}") @Value("${remoteUrl}")
private String remoteUrl; private String remoteUrl;
public RemoteClientConfiguration(DevToolsProperties properties) {
this.properties = properties;
}
@Bean @Bean
public static PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer() { public static PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer() {
return new PropertySourcesPlaceholderConfigurer(); return new PropertySourcesPlaceholderConfigurer();

View File

@ -28,7 +28,6 @@ import org.junit.Test;
import org.junit.rules.ExpectedException; import org.junit.rules.ExpectedException;
import org.junit.rules.TemporaryFolder; import org.junit.rules.TemporaryFolder;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.devtools.filewatch.ChangedFile; import org.springframework.boot.devtools.filewatch.ChangedFile;
import org.springframework.boot.devtools.filewatch.FileSystemWatcher; import org.springframework.boot.devtools.filewatch.FileSystemWatcher;
import org.springframework.boot.devtools.filewatch.FileSystemWatcherFactory; import org.springframework.boot.devtools.filewatch.FileSystemWatcherFactory;
@ -92,8 +91,11 @@ public class ClassPathFileSystemWatcherTests {
@Configuration @Configuration
public static class Config { public static class Config {
@Autowired public final Environment environment;
public Environment environment;
public Config(Environment environment) {
this.environment = environment;
}
@Bean @Bean
public ClassPathFileSystemWatcher watcher() { public ClassPathFileSystemWatcher watcher() {

View File

@ -16,7 +16,6 @@
package sample.metrics.redis; package sample.metrics.redis;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.actuate.endpoint.MetricReaderPublicMetrics; import org.springframework.boot.actuate.endpoint.MetricReaderPublicMetrics;
import org.springframework.boot.actuate.endpoint.PublicMetrics; import org.springframework.boot.actuate.endpoint.PublicMetrics;
import org.springframework.boot.actuate.metrics.aggregate.AggregateMetricReader; import org.springframework.boot.actuate.metrics.aggregate.AggregateMetricReader;
@ -30,11 +29,15 @@ import org.springframework.data.redis.connection.RedisConnectionFactory;
@Configuration @Configuration
public class AggregateMetricsConfiguration { public class AggregateMetricsConfiguration {
@Autowired private final MetricExportProperties export;
private MetricExportProperties export;
@Autowired private final RedisConnectionFactory connectionFactory;
private RedisConnectionFactory connectionFactory;
public AggregateMetricsConfiguration(MetricExportProperties export,
RedisConnectionFactory connectionFactory) {
this.export = export;
this.connectionFactory = connectionFactory;
}
@Bean @Bean
public PublicMetrics metricsAggregate() { public PublicMetrics metricsAggregate() {

View File

@ -22,7 +22,6 @@ import java.nio.charset.Charset;
import org.junit.After; import org.junit.After;
import org.junit.Test; import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.embedded.jetty.JettyEmbeddedServletContainerFactory; import org.springframework.boot.context.embedded.jetty.JettyEmbeddedServletContainerFactory;
import org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory; import org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory;
import org.springframework.boot.context.embedded.undertow.UndertowEmbeddedServletContainerFactory; import org.springframework.boot.context.embedded.undertow.UndertowEmbeddedServletContainerFactory;
@ -168,8 +167,11 @@ public class EmbeddedServletContainerMvcIntegrationTests {
@PropertySource("classpath:/org/springframework/boot/context/embedded/conf.properties") @PropertySource("classpath:/org/springframework/boot/context/embedded/conf.properties")
public static class AdvancedConfig { public static class AdvancedConfig {
@Autowired private final Environment env;
private Environment env;
public AdvancedConfig(Environment env) {
this.env = env;
}
@Bean @Bean
public EmbeddedServletContainerFactory containerFactory() { public EmbeddedServletContainerFactory containerFactory() {

View File

@ -24,7 +24,6 @@ import org.junit.Test;
import org.junit.rules.ExpectedException; import org.junit.rules.ExpectedException;
import org.springframework.beans.BeansException; import org.springframework.beans.BeansException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.config.BeanPostProcessor; import org.springframework.beans.factory.config.BeanPostProcessor;
import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
@ -170,8 +169,11 @@ public class EntityScanTests {
@EntityScan("com.mycorp.entity") @EntityScan("com.mycorp.entity")
static class BeanPostProcessorConfiguration { static class BeanPostProcessorConfiguration {
@Autowired protected final EntityManagerFactory entityManagerFactory;
protected EntityManagerFactory entityManagerFactory;
BeanPostProcessorConfiguration(EntityManagerFactory entityManagerFactory) {
this.entityManagerFactory = entityManagerFactory;
}
@Bean @Bean
public BeanPostProcessor beanPostProcessor() { public BeanPostProcessor beanPostProcessor() {