How do I create a Map<String, List<String>>
property in properties file that can be injectable using Spring’s @Value?
Example code snippet in Properties java file
JavaScript
x
@PropertySource({"file:salesforce-service.properties"})
public class Properties {
@Value("#{${student.hobbies}}")
private Map<String, List<String>> hobbies;
}
Advertisement
Answer
Here is the answer and the example code snippet in properties file:
JavaScript
student.hobbies={indoor: 'reading, drawing', outdoor: 'fishing, hiking, bushcraft'}
Reference: https://stackabuse.com/the-value-annotation-in-spring/ section –> Injecting into Maps