SpringBoot 的 ApplicationRunner 接口可以让项目在启动时候初始化一些信息 , 比如 数据库连接 , 或者自定义的一些配置等;
步骤 : 重写ApplicationRunner 接口的run方法 , 在run方法中输出你要的配置信息即可.
public class InitLoad implements ApplicationRunner {
@Override
public void run(ApplicationArguments args) throws Exception {
LOGGER.info("InitLoadCacheRunner 加载缓存数据...");
// 加载游戏缓存(redis中拿出所有的游戏gameId)
loadGameCache();
}
}