I have my contents in .properties file. I'm loading the properties file using @PropertySource.
How do i get the contents from the properties file to map using @PropertySource Annotation?
My Property file looks like this:
a= abc
b= bcd
c= cde
In my Component, I want to read the property file and put the contents in a map.
@PropertySource("classpath:myData.properties")
public class myComponentService {
@Autowired
private Environment environment;
Map<String, String> myMap = new HashMap<String, String>(); //Property file content goes here
}
I tried something like this, but this doesn't work.
Map<String, String> myMap= new HashMap<String, String>();
Properties myProperties = new Properties();
myProperties .putAll(myMap);