鄙人所学三种方式:
1、(已验证过)
1)创建一个配置类,类上添加注解@Component;
2)声明一个返回类型为 void 的方法;
3)方法添加注解 @PostConstruct;
2、(未验证)
1)实现ApplicationRunner接口
2)重写run方法,在run方法中设置缓存即可
PS:据说会在项目启动成功前就会执行
3、(未验证)
1)实现CommandLineRunner接口
2)重写run方法,在run方法中设置缓存即可
鄙人所学三种方式:
1、(已验证过)
1)创建一个配置类,类上添加注解@Component;
2)声明一个返回类型为 void 的方法;
3)方法添加注解 @PostConstruct;
2、(未验证)
1)实现ApplicationRunner接口
2)重写run方法,在run方法中设置缓存即可
PS:据说会在项目启动成功前就会执行
3、(未验证)
1)实现CommandLineRunner接口
2)重写run方法,在run方法中设置缓存即可