1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
| @Component @Slf4j public class ApolloConfigRefresher implements ApplicationContextAware {
@Autowired private ApplicationContext applicationContext;
@ApolloConfigChangeListener public void onChange(ConfigChangeEvent changeEvent) { // TODO 在此处监听发生改变的参数,若为连接池的参数需要重新加载链接池
this.applicationContext.publishEvent(new EnvironmentChangeEvent(changeEvent.changedKeys())); }
@Override public void setApplicationContext(ApplicationContext applicationContext) throws BeansException { this.applicationContext = applicationContext; }
}
|