zoukankan      html  css  js  c++  java
  • springboot--启动服务自动加载额外配置实现

    实现CommandLineRunner 接口,springboot在启动时会自动调用run方法。通过@Order注解可以指定执行顺序。

    import org.slf4j.Logger;
    import org.slf4j.LoggerFactory;
    import org.springframework.beans.factory.annotation.Autowired;
    import org.springframework.boot.CommandLineRunner;
    import org.springframework.core.annotation.Order;
    import org.springframework.stereotype.Component;
    
    @Component
    @Order(1)
    public class InitExtraResource implements CommandLineRunner {
    
      @Autowired
      MetadataDubboService metadataDubboService;
    
      public static final Logger logger = LoggerFactory.getLogger(InitExtraResource.class);
    
    
      @Override
      public void run(String... strings) {
        logger.info("缓存数据库信息初始化开始。。。");
        metadataDubboService.refreshCache("ALL");//多线程实现,否则阻塞主线程
        logger.info("缓存数据库信息初始化成功!");
      }
    }
  • 相关阅读:
    爬虫框架scrapy(1)持久化存储的多种方式及多页爬取数据
    爬虫之selenium
    redis相关
    爬虫之数据解析
    爬虫之requests模块2
    爬虫之requests模块
    HTTP和HTTPS协议
    Pymongo使用
    MongoDB
    python网络编程之黏包问题
  • 原文地址:https://www.cnblogs.com/jvStarBlog/p/11136167.html
Copyright © 2011-2022 走看看