2

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

@PropertySource({"file:salesforce-service.properties"})
public class Properties {
    @Value("#{${student.hobbies}}")
    private Map<String, List<String>> hobbies;
}
Mark Rotteveel
  • 100,966
  • 191
  • 140
  • 197
Artanis Zeratul
  • 963
  • 2
  • 14
  • 40

1 Answers1

3

Here is the answer and the example code snippet in properties file:

student.hobbies={indoor: 'reading, drawing', outdoor: 'fishing, hiking, bushcraft'}

Reference: https://stackabuse.com/the-value-annotation-in-spring/ section --> Injecting into Maps

Artanis Zeratul
  • 963
  • 2
  • 14
  • 40