@Value "Could not resolve placeholder" in Spring Boot Test

You need to add

@PropertySource("classpath:application.properties")

to your class, so it will pick your normal configurations.

If you need different configurations for test you can add

@TestPropertySource(locations="classpath:test.properties")

If not just copy paste your config file to test/resources folder, then boot will pick from there.

See this.


You can use the @SpringBootTest that will do create the PropertySourcesPlaceholderConfigurer automatically.

This is described in the Testing chapter of the Spring Boot documentation.

http://docs.spring.io/spring-boot/docs/current/reference/html/boot-features-testing.html#boot-features-configfileapplicationcontextinitializer-test-utility