From 821ee0cf830d9116d6d9a4f9911c16fb255481d1 Mon Sep 17 00:00:00 2001 From: Andy Wilkinson Date: Mon, 11 Mar 2019 15:01:59 +0000 Subject: [PATCH] Ensure that @Bean methods are only declared on @Configuration classes Closes gh-16190 --- .../autoconfigure/EndpointAutoConfigurationTests.java | 3 ++- ...ndpointWebMvcManagementContextConfigurationTests.java | 9 ++++++++- .../HealthIndicatorAutoConfigurationTests.java | 3 ++- ...PersistenceExceptionTranslationAutoConfiguration.java | 4 +++- .../HypermediaHttpMessageConverterConfiguration.java | 4 +++- .../boot/autoconfigure/jdbc/DataSourceConfiguration.java | 8 +++++++- .../jdbc/XADataSourceAutoConfiguration.java | 4 +++- .../autoconfigure/batch/BatchAutoConfigurationTests.java | 5 ++++- .../condition/ConditionalOnPropertyTests.java | 4 +++- .../jdbc/JndiDataSourceAutoConfigurationTests.java | 9 ++++++--- .../kafka/KafkaAutoConfigurationIntegrationTests.java | 4 +++- .../ResourceServerTokenServicesConfigurationTests.java | 4 +++- .../web/MultipartAutoConfigurationTests.java | 4 +++- .../websocket/WebSocketAutoConfigurationTests.java | 3 ++- .../remote/client/RemoteClientConfiguration.java | 5 ++++- .../sample/parent/SampleParentContextApplication.java | 4 +++- .../autoconfigure/json/JsonTestersAutoConfiguration.java | 8 +++++--- .../BeanCurrentlyInCreationFailureAnalyzerTests.java | 4 +++- .../NoUniqueBeanDefinitionFailureAnalyzerTests.java | 3 ++- .../web/servlet/ServletContextInitializerBeansTests.java | 5 ++++- 20 files changed, 73 insertions(+), 24 deletions(-) diff --git a/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/autoconfigure/EndpointAutoConfigurationTests.java b/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/autoconfigure/EndpointAutoConfigurationTests.java index 1010d900fd9..92ca164e8fa 100644 --- a/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/autoconfigure/EndpointAutoConfigurationTests.java +++ b/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/autoconfigure/EndpointAutoConfigurationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2016 the original author or authors. + * Copyright 2012-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -334,6 +334,7 @@ public class EndpointAutoConfigurationTests { } + @Configuration static class DataSourceConfig { @Bean diff --git a/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/autoconfigure/EndpointWebMvcManagementContextConfigurationTests.java b/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/autoconfigure/EndpointWebMvcManagementContextConfigurationTests.java index c330a16cf1c..232fa0df4d9 100644 --- a/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/autoconfigure/EndpointWebMvcManagementContextConfigurationTests.java +++ b/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/autoconfigure/EndpointWebMvcManagementContextConfigurationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2018 the original author or authors. + * Copyright 2012-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -198,6 +198,7 @@ public class EndpointWebMvcManagementContextConfigurationTests { } + @Configuration static class EnvConfiguration { @Bean @@ -208,6 +209,7 @@ public class EndpointWebMvcManagementContextConfigurationTests { } + @Configuration static class MetricsConfiguration { @Bean @@ -217,6 +219,7 @@ public class EndpointWebMvcManagementContextConfigurationTests { } + @Configuration static class LoggersConfiguration { @Bean @@ -236,6 +239,7 @@ public class EndpointWebMvcManagementContextConfigurationTests { } + @Configuration static class LogFileConfiguration { @Bean @@ -245,6 +249,7 @@ public class EndpointWebMvcManagementContextConfigurationTests { } + @Configuration static class AuditEventsConfiguration { @Bean @@ -264,6 +269,7 @@ public class EndpointWebMvcManagementContextConfigurationTests { } + @Configuration static class HeapdumpConfiguration { @Bean @@ -273,6 +279,7 @@ public class EndpointWebMvcManagementContextConfigurationTests { } + @Configuration static class ShutdownConfiguration { @Bean diff --git a/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/autoconfigure/HealthIndicatorAutoConfigurationTests.java b/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/autoconfigure/HealthIndicatorAutoConfigurationTests.java index 8175809dc3a..aef97756c2e 100644 --- a/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/autoconfigure/HealthIndicatorAutoConfigurationTests.java +++ b/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/autoconfigure/HealthIndicatorAutoConfigurationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2017 the original author or authors. + * Copyright 2012-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -627,6 +627,7 @@ public class HealthIndicatorAutoConfigurationTests { } + @Configuration protected static class JestClientConfiguration { @Bean diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/dao/PersistenceExceptionTranslationAutoConfiguration.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/dao/PersistenceExceptionTranslationAutoConfiguration.java index ad5274f2d76..63008dd5e50 100644 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/dao/PersistenceExceptionTranslationAutoConfiguration.java +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/dao/PersistenceExceptionTranslationAutoConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2018 the original author or authors. + * Copyright 2012-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,6 +22,7 @@ import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; import org.springframework.boot.bind.RelaxedPropertyResolver; import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; import org.springframework.core.env.Environment; import org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor; @@ -33,6 +34,7 @@ import org.springframework.dao.annotation.PersistenceExceptionTranslationPostPro * @author Stephane Nicoll * @since 1.2.0 */ +@Configuration @ConditionalOnClass(PersistenceExceptionTranslationPostProcessor.class) public class PersistenceExceptionTranslationAutoConfiguration { diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/hateoas/HypermediaHttpMessageConverterConfiguration.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/hateoas/HypermediaHttpMessageConverterConfiguration.java index 2b61ee36bd2..af89b87cbcd 100644 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/hateoas/HypermediaHttpMessageConverterConfiguration.java +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/hateoas/HypermediaHttpMessageConverterConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2017 the original author or authors. + * Copyright 2012-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -29,6 +29,7 @@ import org.springframework.beans.factory.ListableBeanFactory; import org.springframework.beans.factory.config.BeanPostProcessor; import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; import org.springframework.hateoas.mvc.TypeConstrainedMappingJackson2HttpMessageConverter; import org.springframework.http.MediaType; import org.springframework.http.converter.AbstractHttpMessageConverter; @@ -41,6 +42,7 @@ import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandl * * @author Andy Wilkinson */ +@Configuration public class HypermediaHttpMessageConverterConfiguration { @Bean diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jdbc/DataSourceConfiguration.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jdbc/DataSourceConfiguration.java index 3c36b86b00e..47d096932a9 100644 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jdbc/DataSourceConfiguration.java +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jdbc/DataSourceConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2018 the original author or authors. + * Copyright 2012-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -26,6 +26,7 @@ import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.boot.jdbc.DatabaseDriver; import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; /** * Actual DataSource configurations imported by {@link DataSourceAutoConfiguration}. @@ -45,6 +46,7 @@ abstract class DataSourceConfiguration { /** * Tomcat Pool DataSource configuration. */ + @Configuration @ConditionalOnClass(org.apache.tomcat.jdbc.pool.DataSource.class) @ConditionalOnMissingBean(DataSource.class) @ConditionalOnProperty(name = "spring.datasource.type", havingValue = "org.apache.tomcat.jdbc.pool.DataSource", matchIfMissing = true) @@ -71,6 +73,7 @@ abstract class DataSourceConfiguration { /** * Hikari DataSource configuration. */ + @Configuration @ConditionalOnClass(HikariDataSource.class) @ConditionalOnMissingBean(DataSource.class) @ConditionalOnProperty(name = "spring.datasource.type", havingValue = "com.zaxxer.hikari.HikariDataSource", matchIfMissing = true) @@ -89,6 +92,7 @@ abstract class DataSourceConfiguration { * * @deprecated as of 1.5 in favor of DBCP2 */ + @Configuration @ConditionalOnClass(org.apache.commons.dbcp.BasicDataSource.class) @ConditionalOnMissingBean(DataSource.class) @ConditionalOnProperty(name = "spring.datasource.type", havingValue = "org.apache.commons.dbcp.BasicDataSource", matchIfMissing = true) @@ -116,6 +120,7 @@ abstract class DataSourceConfiguration { /** * DBCP DataSource configuration. */ + @Configuration @ConditionalOnClass(org.apache.commons.dbcp2.BasicDataSource.class) @ConditionalOnMissingBean(DataSource.class) @ConditionalOnProperty(name = "spring.datasource.type", havingValue = "org.apache.commons.dbcp2.BasicDataSource", matchIfMissing = true) @@ -134,6 +139,7 @@ abstract class DataSourceConfiguration { /** * Generic DataSource configuration. */ + @Configuration @ConditionalOnMissingBean(DataSource.class) @ConditionalOnProperty(name = "spring.datasource.type") static class Generic { diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jdbc/XADataSourceAutoConfiguration.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jdbc/XADataSourceAutoConfiguration.java index 95dad6c4365..bc729a41bd6 100644 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jdbc/XADataSourceAutoConfiguration.java +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jdbc/XADataSourceAutoConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2016 the original author or authors. + * Copyright 2012-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -34,6 +34,7 @@ import org.springframework.boot.context.properties.EnableConfigurationProperties import org.springframework.boot.jdbc.DatabaseDriver; import org.springframework.boot.jta.XADataSourceWrapper; import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseType; import org.springframework.util.Assert; import org.springframework.util.ClassUtils; @@ -46,6 +47,7 @@ import org.springframework.util.StringUtils; * @author Josh Long * @since 1.2.0 */ +@Configuration @AutoConfigureBefore(DataSourceAutoConfiguration.class) @EnableConfigurationProperties(DataSourceProperties.class) @ConditionalOnClass({ DataSource.class, TransactionManager.class, diff --git a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/batch/BatchAutoConfigurationTests.java b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/batch/BatchAutoConfigurationTests.java index f8b47a54437..fd46a0bc112 100644 --- a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/batch/BatchAutoConfigurationTests.java +++ b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/batch/BatchAutoConfigurationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2017 the original author or authors. + * Copyright 2012-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -371,6 +371,7 @@ public class BatchAutoConfigurationTests { } @EnableBatchProcessing + @Configuration protected static class NamedJobConfigurationWithRegisteredJob { @Autowired @@ -413,6 +414,7 @@ public class BatchAutoConfigurationTests { } @EnableBatchProcessing + @Configuration protected static class NamedJobConfigurationWithLocalJob { @Autowired @@ -444,6 +446,7 @@ public class BatchAutoConfigurationTests { } + @Configuration @EnableBatchProcessing protected static class JobConfiguration { diff --git a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/condition/ConditionalOnPropertyTests.java b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/condition/ConditionalOnPropertyTests.java index 13ae5bb448e..8e49a6f602a 100644 --- a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/condition/ConditionalOnPropertyTests.java +++ b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/condition/ConditionalOnPropertyTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2016 the original author or authors. + * Copyright 2012-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -434,6 +434,7 @@ public class ConditionalOnPropertyTests { } + @Configuration @ConditionalOnMyFeature protected static class MetaAnnotation { @@ -444,6 +445,7 @@ public class ConditionalOnPropertyTests { } + @Configuration @ConditionalOnMyFeature @ConditionalOnProperty(prefix = "my.other.feature", name = "enabled", havingValue = "true", matchIfMissing = false) protected static class MetaAnnotationAndDirectAnnotation { diff --git a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/jdbc/JndiDataSourceAutoConfigurationTests.java b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/jdbc/JndiDataSourceAutoConfigurationTests.java index fedc3e1611e..5d807afacca 100644 --- a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/jdbc/JndiDataSourceAutoConfigurationTests.java +++ b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/jdbc/JndiDataSourceAutoConfigurationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2017 the original author or authors. + * Copyright 2012-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -33,6 +33,7 @@ import org.springframework.boot.autoconfigure.jndi.TestableInitialContextFactory import org.springframework.boot.test.util.EnvironmentTestUtils; import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; import org.springframework.jmx.export.MBeanExporter; import static org.assertj.core.api.Assertions.assertThat; @@ -167,7 +168,8 @@ public class JndiDataSourceAutoConfigurationTests { TestableInitialContextFactory.bind(name, dataSource); } - private static class MBeanExporterConfiguration { + @Configuration + static class MBeanExporterConfiguration { @Bean MBeanExporter mbeanExporter() { @@ -176,7 +178,8 @@ public class JndiDataSourceAutoConfigurationTests { } - private static class AnotherMBeanExporterConfiguration { + @Configuration + static class AnotherMBeanExporterConfiguration { @Bean MBeanExporter anotherMbeanExporter() { diff --git a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/kafka/KafkaAutoConfigurationIntegrationTests.java b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/kafka/KafkaAutoConfigurationIntegrationTests.java index 92e72ecbbd0..d3c662c66f5 100644 --- a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/kafka/KafkaAutoConfigurationIntegrationTests.java +++ b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/kafka/KafkaAutoConfigurationIntegrationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2018 the original author or authors. + * Copyright 2012-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -29,6 +29,7 @@ import org.junit.Test; import org.springframework.boot.test.util.EnvironmentTestUtils; import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; import org.springframework.kafka.annotation.KafkaListener; import org.springframework.kafka.core.KafkaTemplate; import org.springframework.kafka.support.KafkaHeaders; @@ -98,6 +99,7 @@ public class KafkaAutoConfigurationIntegrationTests { return File.separatorChar == '\\'; } + @Configuration public static class KafkaConfig { @Bean diff --git a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/security/oauth2/resource/ResourceServerTokenServicesConfigurationTests.java b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/security/oauth2/resource/ResourceServerTokenServicesConfigurationTests.java index 0cc434c5620..4b3337a0e7b 100644 --- a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/security/oauth2/resource/ResourceServerTokenServicesConfigurationTests.java +++ b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/security/oauth2/resource/ResourceServerTokenServicesConfigurationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2017 the original author or authors. + * Copyright 2012-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -324,6 +324,7 @@ public class ResourceServerTokenServicesConfigurationTests { } + @Configuration @Import({ OAuth2RestOperationsConfiguration.class }) protected static class ResourceNoClientConfiguration extends ResourceConfiguration { @@ -351,6 +352,7 @@ public class ResourceServerTokenServicesConfigurationTests { } + @Configuration @Import({ FacebookAutoConfiguration.class, SocialWebAutoConfiguration.class }) protected static class SocialResourceConfiguration extends ResourceConfiguration { diff --git a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/MultipartAutoConfigurationTests.java b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/MultipartAutoConfigurationTests.java index ae1650fd85f..ac342684832 100644 --- a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/MultipartAutoConfigurationTests.java +++ b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/MultipartAutoConfigurationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2018 the original author or authors. + * Copyright 2012-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -373,6 +373,7 @@ public class MultipartAutoConfigurationTests { } + @Configuration public static class ContainerWithCustomMultipartResolver { @Bean @@ -382,6 +383,7 @@ public class MultipartAutoConfigurationTests { } + @Configuration public static class ContainerWithCommonsMultipartResolver { @Bean diff --git a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/websocket/WebSocketAutoConfigurationTests.java b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/websocket/WebSocketAutoConfigurationTests.java index 1ad3738297a..34107b108b0 100644 --- a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/websocket/WebSocketAutoConfigurationTests.java +++ b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/websocket/WebSocketAutoConfigurationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2017 the original author or authors. + * Copyright 2012-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -89,6 +89,7 @@ public class WebSocketAutoConfigurationTests { } + @Configuration static class CommonConfiguration { @Bean diff --git a/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/remote/client/RemoteClientConfiguration.java b/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/remote/client/RemoteClientConfiguration.java index ad7ae524bdc..6847a0ee016 100644 --- a/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/remote/client/RemoteClientConfiguration.java +++ b/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/remote/client/RemoteClientConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2016 the original author or authors. + * Copyright 2012-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -133,6 +133,7 @@ public class RemoteClientConfiguration { /** * LiveReload configuration. */ + @Configuration @ConditionalOnProperty(prefix = "spring.devtools.livereload", name = "enabled", matchIfMissing = true) static class LiveReloadConfiguration { @@ -179,6 +180,7 @@ public class RemoteClientConfiguration { /** * Client configuration for remote update and restarts. */ + @Configuration @ConditionalOnProperty(prefix = "spring.devtools.remote.restart", name = "enabled", matchIfMissing = true) static class RemoteRestartClientConfiguration { @@ -242,6 +244,7 @@ public class RemoteClientConfiguration { /** * Client configuration for remote debug HTTP tunneling. */ + @Configuration @ConditionalOnProperty(prefix = "spring.devtools.remote.debug", name = "enabled", matchIfMissing = true) @ConditionalOnClass(Filter.class) @Conditional(LocalDebugPortAvailableCondition.class) diff --git a/spring-boot-samples/spring-boot-sample-parent-context/src/main/java/sample/parent/SampleParentContextApplication.java b/spring-boot-samples/spring-boot-sample-parent-context/src/main/java/sample/parent/SampleParentContextApplication.java index 617fee62a0a..e3465f6276c 100644 --- a/spring-boot-samples/spring-boot-sample-parent-context/src/main/java/sample/parent/SampleParentContextApplication.java +++ b/spring-boot-samples/spring-boot-sample-parent-context/src/main/java/sample/parent/SampleParentContextApplication.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2018 the original author or authors. + * Copyright 2012-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -23,6 +23,7 @@ import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.builder.SpringApplicationBuilder; import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; import org.springframework.integration.channel.DirectChannel; import org.springframework.integration.dsl.IntegrationFlow; import org.springframework.integration.dsl.IntegrationFlows; @@ -41,6 +42,7 @@ public class SampleParentContextApplication { .child(SampleParentContextApplication.class).run(args); } + @Configuration @EnableAutoConfiguration protected static class Parent { diff --git a/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/json/JsonTestersAutoConfiguration.java b/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/json/JsonTestersAutoConfiguration.java index 3adc86f2d1c..ad3681b91d2 100644 --- a/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/json/JsonTestersAutoConfiguration.java +++ b/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/json/JsonTestersAutoConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2017 the original author or authors. + * Copyright 2012-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -70,8 +70,9 @@ public class JsonTestersAutoConfiguration { null); } + @Configuration @ConditionalOnClass(ObjectMapper.class) - private static class JacksonJsonTestersConfiguration { + static class JacksonJsonTestersConfiguration { @Bean @Scope("prototype") @@ -84,8 +85,9 @@ public class JsonTestersAutoConfiguration { } + @Configuration @ConditionalOnClass(Gson.class) - private static class GsonJsonTestersConfiguration { + static class GsonJsonTestersConfiguration { @Bean @Scope("prototype") diff --git a/spring-boot/src/test/java/org/springframework/boot/diagnostics/analyzer/BeanCurrentlyInCreationFailureAnalyzerTests.java b/spring-boot/src/test/java/org/springframework/boot/diagnostics/analyzer/BeanCurrentlyInCreationFailureAnalyzerTests.java index 49c7b3e39b0..b3bcbd56cea 100644 --- a/spring-boot/src/test/java/org/springframework/boot/diagnostics/analyzer/BeanCurrentlyInCreationFailureAnalyzerTests.java +++ b/spring-boot/src/test/java/org/springframework/boot/diagnostics/analyzer/BeanCurrentlyInCreationFailureAnalyzerTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2017 the original author or authors. + * Copyright 2012-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -242,6 +242,7 @@ public class BeanCurrentlyInCreationFailureAnalyzerTests { return new BeanOne(); } + @org.springframework.context.annotation.Configuration public static class BeanTwoConfiguration { @SuppressWarnings("unused") @@ -255,6 +256,7 @@ public class BeanCurrentlyInCreationFailureAnalyzerTests { } + @org.springframework.context.annotation.Configuration public static class BeanThreeConfiguration { @Bean diff --git a/spring-boot/src/test/java/org/springframework/boot/diagnostics/analyzer/NoUniqueBeanDefinitionFailureAnalyzerTests.java b/spring-boot/src/test/java/org/springframework/boot/diagnostics/analyzer/NoUniqueBeanDefinitionFailureAnalyzerTests.java index 036189f6339..5f040029257 100644 --- a/spring-boot/src/test/java/org/springframework/boot/diagnostics/analyzer/NoUniqueBeanDefinitionFailureAnalyzerTests.java +++ b/spring-boot/src/test/java/org/springframework/boot/diagnostics/analyzer/NoUniqueBeanDefinitionFailureAnalyzerTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2016 the original author or authors. + * Copyright 2012-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -154,6 +154,7 @@ public class NoUniqueBeanDefinitionFailureAnalyzerTests { } + @Configuration static class ParentProducer { @Bean diff --git a/spring-boot/src/test/java/org/springframework/boot/web/servlet/ServletContextInitializerBeansTests.java b/spring-boot/src/test/java/org/springframework/boot/web/servlet/ServletContextInitializerBeansTests.java index 86446b3565d..8fc36db87bd 100644 --- a/spring-boot/src/test/java/org/springframework/boot/web/servlet/ServletContextInitializerBeansTests.java +++ b/spring-boot/src/test/java/org/springframework/boot/web/servlet/ServletContextInitializerBeansTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2017 the original author or authors. + * Copyright 2012-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -32,6 +32,7 @@ import org.junit.Test; import org.springframework.context.ConfigurableApplicationContext; import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; import static org.assertj.core.api.Assertions.assertThat; @@ -66,6 +67,7 @@ public class ServletContextInitializerBeansTests { this.context = new AnnotationConfigApplicationContext(configuration); } + @Configuration static class ServletConfiguration { @Bean @@ -75,6 +77,7 @@ public class ServletContextInitializerBeansTests { } + @Configuration static class FilterConfiguration { @Bean