Before migrating our Spring Boot 1.3
application to 1.4
, when running integration tests, we used to load our application-test.yml
file from src/main/resources/config/
folder which would override properties from an application.yml
file that was loaded from src/test/resources/config/
folder.
However, with the new version of Spring Boot
and its test suite it seems that while bootstrapping the application for testing, it no longer checks the resources folder under src/main
. It instead only checks the resources
that are location under src/test/
and is looking for .yml
files only under that folder's config/
folder.
Is there a way to tell Spring Boot
that it should be looking for .yml
files under both resources
folders?
It is better to have fully separated resources. Definitely, you should think about that. But, cut the long story short, you could try to do something like this:
@TestPropertySource(locations = {
"classpath:test.yml",
"classpath:test-override.yml" })
If you have *.yml
, then don't forget to declare the following line above your class:
@ContextConfiguration(initializers = ConfigFileApplicationContextInitializer.class)
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments