I am using component-scan in my spring application. So in spring context I created map:
If I were you, I would use Java Config to create a Map, since Java is the best way to create a Java object :) :). Your configuration code would look like this:
@Bean(name = "mapBean")
public Map mapBean() {
Map map = new HashMap<>();
//populate the map here - you will need to @Autowire the references if they are not defined in this configuration
return map;
}
And then I would inject it into wherever it's needed like so:
@Resource(name="mapBean")
private Map map;
Note the use of @Resource instead of @Autowired or @Inject