我的專案中有幾個使用@Valueannotion 的bean 。
如果我不使用@ActiveProfiles和運行帶有下面配置的文本,一切都很好。
spring:
profiles:
active: localhost,schedule_off
但是如果我使用@ActiveProfiles,會有例外說
“無法決議占位符 XXX”。
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
@ActiveProfiles("localhost,schedule_off")
為什么會這樣以及如何解決?
uj5u.com熱心網友回復:
實際問題是(簡單地):
@ActiveProfiles采用而String[]不是逗號分隔的字串引數。
所以請嘗試(完全不同的):
@ActiveProfiles({"localhost", "schedule_off"})
相反(經過測驗/有效!;)。
uj5u.com熱心網友回復:
這個怎么樣?
spring:
config:
activate:
on-profile: localhost,schedule_off
轉載請註明出處,本文鏈接:https://www.uj5u.com/yidong/386771.html
