//创建类,并实现CommandLineRunner接口
public class ApplicationStartupRunner implements CommandLineRunner {
//重写run(),在项目启动后,执行了SpringApplication.run(SpringBootWebApplication.class, args);后,会执行此方法
//通常用于项目启动时自动加载一些配置,缓存。比如存一些数据库的配置到redis
@Override
public void run(String... args) throws Exception {
logger.info("Application Started !!");
}
}
CommandLineRunner
最新推荐文章于 2024-12-03 18:52:06 发布
该代码示例展示了一个实现了CommandLineRunner接口的类,当SpringBoot应用启动后,`run`方法会被调用,常用于在项目启动时自动处理如加载配置到Redis等初始化任务。
1002

被折叠的 条评论
为什么被折叠?



