Skip to content

Commit 91c7bc9

Browse files
committed
TestContext: define PropertySourcesPlaceholderConfigurer as static.
Fix the warning from Spring Test Framework: 2016-08-22 23:30:28.746 WARN --- [ main] o.s.c.a.ConfigurationClassEnhancer: @bean method TestContext.getPropertySourcesPlaceholderConfigurer is non-static and returns an object assignable to Spring's BeanFactoryPostProcessor interface. This will result in a failure to process annotations such as @Autowired, @resource and @PostConstruct within the method's declaring @configuration class. Add the 'static' modifier to this method to avoid these container lifecycle issues; see @bean javadoc for complete details. No functional changes.
1 parent 765ae46 commit 91c7bc9

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/test/java/ru/mystamps/web/config/TestContext.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,13 @@
2222
import org.springframework.context.support.PropertySourcesPlaceholderConfigurer;
2323
import org.springframework.core.io.ClassPathResource;
2424

25+
// CheckStyle: no, it isn't utility class, it's a configuration with a single bean
26+
@SuppressWarnings("checkstyle:hideutilityclassconstructor")
2527
@Configuration
2628
public class TestContext {
2729

2830
@Bean
29-
public PropertySourcesPlaceholderConfigurer getPropertySourcesPlaceholderConfigurer() {
31+
public static PropertySourcesPlaceholderConfigurer getPropertySourcesPlaceholderConfigurer() {
3032
PropertySourcesPlaceholderConfigurer configurer =
3133
new PropertySourcesPlaceholderConfigurer();
3234
configurer.setLocations(

0 commit comments

Comments
 (0)