public void afterPropertiesSet() throws Exception { Map<String, DataSourceRegister> dataSourceRegisters = applicationContext.getBeansOfType(DataSourceRegister.class); for (DataSourceRegister dataSourceRegister : dataSourceRegisters.values()) { dataSources.put(dataSourceRegister.getName(), dataSourceRegister.getDataSource()); JdbcDaoSupport jdbcDaoSupport = new JdbcDaoSupport(){}; jdbcDaoSupport.setDataSource(dataSourceRegister.getDataSource()); jdbcTemplateMap.put(dataSourceRegister.getName(),jdbcDaoSupport.getJdbcTemplate()); if(dataSourceRegister.isAsDefault()){ defaultDataSourceName=dataSourceRegister.getName(); this.defaultJdbcTemplate=jdbcDaoSupport.getJdbcTemplate(); } } }