0
CustomProperties對象位於外部庫中,因此我無法添加註釋,但我仍然希望通過前綴將其從Spring Boot YAML中提供。@ConfigurationProperties(prefix =「foo」)等價於一個外部Properties對象嗎?
CustomProperties對象位於外部庫中,因此我無法添加註釋,但我仍然希望通過前綴將其從Spring Boot YAML中提供。@ConfigurationProperties(prefix =「foo」)等價於一個外部Properties對象嗎?
找到了!
在@Configuration:
@Bean
@ConfigurationProperties("company.custom")
public CustomProperties customProperties(){
return new CustomProperties();
}
你是如何初始化'CustomProperties'類?這個類是否有'@Component或@ Service'註解? –
仍然沒有這樣做,即時只是評估如何攻擊它,理想情況下,我會保存自己複製並轉換我的啓動域應用程序中的CustomProperties類 – Whimusical