zuul服务网关启动手动监听

@Component
@Slf4j
public class MyCommandLineRunner implements CommandLineRunner {

    @ApolloConfig
    private Config config;

    @Override
    public void run(String... args) throws Exception {
        log.info("MyCommandLineRunner启动成功!");

        //Apollo监听办法
        config.addChangeListener(new ConfigChangeListener() {
            @Override
            public void onChange(ConfigChangeEvent changeEvent) {
                log.debug("####分布式配置中心监听器"+ changeEvent.changedKeys().toString());
            }
        });
    }
}

当项目启动的时候开始加载这个类
zuul服务网关启动手动监听.png

Last modification:May 17th, 2019 at 08:14 pm
如果觉得这篇技术文章对你有用,请随意赞赏

Leave a Comment