I tried a spring boot 2.4.0 application, wrote some tests. Here's my test class
@SpringBootTest
@ActiveProfiles("test")
@TestPropertySource(locations = "classpath:application-test.properties")
public class SampleTest {
@Test
public void testMethod1() {
//some logic
}
}
I have this structure
src/
main/
java/
//// further packages
resources/
bootstrap.yml
test/
resources/
application-test.properties
Above code is picking bootstrap.yml as it contains this property spring.profiles.active=${PROFILE} Btw, this application is using spring-cloud-config
It gives this error
java.lang.IllegalStateException: Failed to load ApplicationContext
Caused by: java.lang.IllegalArgumentException: Could not resolve placeholder 'PROFILE' in value "${PROFILE}"
Why is spring-boot not picking up my test properties file? It is giving precedence to bootstrap.yml file always. Please help
application-test.propertiestoapplication.ymlinsrc/test/resource