Hello,
I guess this is a bug in STS (2.6.1), I get a "Spring Beans Problem" when having a static method annotated with @Bean, but if you look into the @Bean-javadoc you see that this is the suggested approach for BeanFactoryPostProcessors.
I have a @Configuration class like this:
The "Spring Bean Problem" is on the method propertySourcesPlaceholderConfigurer() and tells me that the method must not be private, static or final.Code:@Configuration public class DataConfig { @Value("${jdbc.url}") String url; @Value("${jdbc.username}") String username; @Value("${jdbc.password}") String password; @Bean public static PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer(){ PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer = new PropertySourcesPlaceholderConfigurer(); propertySourcesPlaceholderConfigurer.setLocation(new ClassPathResource("database.properties")); return propertySourcesPlaceholderConfigurer; } @Bean public DataSource dataSource(){ BasicDataSource dataSource = new BasicDataSource(); dataSource.setUrl(url); dataSource.setUsername(username); dataSource.setPassword(password); return dataSource; } @Bean public PlatformTransactionManager transactionManager(){ return new DataSourceTransactionManager(dataSource()); } }
However, the configuration class compiles and works fine in tests. The red problem sign is just annoying.


Reply With Quote
