I need to set a map as a spring bean. I have a map which is intialized in init() method with @PostConstruct keyword.
public class CustomerService
{
@Autowired
TestService testService;
static Map<String, String> someMap;
@PostConstruct
public void initIt() throws Exception {
someMap = new HashMap<String, String>();
someMap = // some code by calling testService
}
@PreDestroy
public void cleanUp() throws Exception {}
}
I call this from applicationContext.xml as a bean.
<bean id="customerService" class="test.com.customer.CustomerService"/>
Initializing the map is working properly, i need to assign the value of this map into bean in order to access the value of the bean in somewhere else in the application.
I found examples of setting up map as a bean, but all were done in XML configurations. How to inject a Map in java springs
How can i achieve this task. Any knowledge is highly appreciated.