Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- com:
- db:
- dbcp2:
- host: localhost:3309
- driverClassName: com.mysql.jdbc.Driver
- username: user
- password: password
- publisher:
- url: jdbc:mysql://${com.db.host}/common
- objects:
- url: jdbc:mysql://${com.db.host}/trc
- ConfigurationPropertiesBindingPostProcessor postProcessor = new ConfigurationPropertiesBindingPostProcessor();
- postProcessor.setApplicationContext(applicationContext);
- postProcessor.setBeanFactory(beanFactory);
- postProcessor.setEnvironment(environment);
- postProcessor.setPropertySources(environment.getPropertySources());
- postProcessor.setResourceLoader(applicationContext);
- try {
- bindingPostProcessor.afterPropertiesSet();
- } catch (Exception e) {
- e.printStackTrace();
- }
- DBCP2Properties dbcp2Properties = new DBCP2Properties();
- bindingPostProcessor.postProcessBeforeInitialization(dbcp2Properties,"dbcp2");
- @ConfigurationProperties(prefix = "com.db")
- public static class DBCP2Properties{
- private Map<String,Object> dbcp2 = new HashedMap();
- public Map<String, Object> getDbcp2() {
- return dbcp2;
- }
- public void setDbcp2(Map<String, Object> dbcp2) {
- this.dbcp2 = dbcp2;
- }
- }
- registry.registerBeanDefinition("publisher-ds",BeanDefinitionBuilder.genericBeanDefinition(BasicDataSource.class).getBeanDefinition());
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement