Issue
I have several beans using @Value
annotion in my project.
If I don't use @ActiveProfiles
and run test with config below,everything is fine.
spring:
profiles:
active: localhost,schedule_off
But if I use @ActiveProfiles
,there would be exception says
'Could not resolve placeholder XXX'.
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
@ActiveProfiles("localhost,schedule_off")
Why is that and how to fix it?
Solution
The actual problem is (simply):
@ActiveProfiles takes rather a String[]
than a comma separated string parameter.
So please try (the decently different):
@ActiveProfiles({"localhost", "schedule_off"})
instead (tested/works!;).
Answered By - xerx593