监听 Spring 云领事配置中刷新的上下文

Listening to context Refreshed in Spring cloud consul config

Spring 云领事配置允许在领事中更改 属性 时动态刷新属性。有没有办法在变化发生时监听?

@Component
public class ContextRefreshListener {

@EventListener
public void handleContextRefresh(ContextRefreshedEvent event) {
    System.out.println("refreshed");
}

@EventListener
public void handleContextStart(ContextStartedEvent event) {
    System.out.println("started");
}


@EventListener
public void handleContextRefresh(ApplicationContextEvent event) {
    System.out.println("context");
}

}

以上三个事件我都试过了,都没有成功。有什么办法可以在刷新发生时监听事件吗?

我是通过以下方式做到的

@EventListener
public void handleContextStart(EnvironmentChangeEvent event) {
    System.out.println("changed");
    //Use this for getting the version from consul

}