![](/img/trans.png)
[英]how to make a map of properties using formatted string "Property:Value"
[英]How to create a Map<String, List<String>> property in properties file that can be injectable using Spring's @Value
如何在屬性文件中創建可以使用 Spring 的 @Value 注入的Map<String, List<String>>
屬性?
屬性 java 文件中的示例代碼片段
@PropertySource({"file:salesforce-service.properties"})
public class Properties {
@Value("#{${student.hobbies}}")
private Map<String, List<String>> hobbies;
}
這是答案和屬性文件中的示例代碼片段:
student.hobbies={indoor: 'reading, drawing', outdoor: 'fishing, hiking, bushcraft'}
參考: https://stackabuse.com/the-value-annotation-in-spring/部分 --> 注入 Maps
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.