I use Spring 4.2.6.RELEASE. During initialization of my app I get such a warning:
[WARN] org.springframework.context.annotation.ConfigurationClassPostPr
Maybe this helps (or not)...
@RunWith(SpringRunner.class)
@DataJpaTest
public class TestMyImpl {
...
I'm using 4.3.4.RELEASE
and have the following warning for the code block above:
2016-12-30 07:33:04.296 WARN 2000 --- [ main] o.s.c.a.ConfigurationClassPostProcessor : Cannot enhance @Configuration bean definition 'embeddedDataSourceBeanFactoryPostProcessor' since its singleton instance has been created too early. The typical cause is a non-static @Bean method with a BeanDefinitionRegistryPostProcessor return type: Consider declaring such methods as 'static'.
Since I use @DataJpaTest
which autoconfigures the test database (h2
in this case) by replacing any dataSource
it finds, the behaviour is expected and wanted. The warning is a confirmation of the overriding behaviour of @DataJpaTest
.
@RunWith(SpringRunner.class)
@DataJpaTest
@AutoConfigureTestDatabase(replace=Replace.NONE)
public class TestMyImpl {
...
By disabling the autoconfiguration (as shown above) the warning disappears. The datasource
can now be configured as usual.