I am using spring/hibernate. i have configured 5 datasources in applicationContext.xml file. All datasources are of com.mchange.v2.c3p0.ComboPooledDataSource type but ids are different. how can i get all the configured datasources when i have application context. i am getting application context as below:
WebApplicationContext context = WebApplicationContextUtils.getRequiredWebApplicationContext(getServletContext());
Thanks!
You can get all beans of the given type as follows:
Values in this
Mapare bean instances, keys are their ids.Alternatively you can inject collection of beans of the given type into another bean as dependency, see 3.9.2 @Autowired and @Inject.