奋斗烤鸡

文章
9
资源
0
加入时间
3年2月3天

Spring Boot之 CommandLineRunner、ApplicationRunner和@PostConstruct

在使用Spring Boot开发的工作中,我们经常会需要遇到一种功能需求,比如在服务启动时候,去加载一些配置,去请求一下其他服务的接口。Spring Boot给我们提供了三种常用的实现方法:第一种是实现CommandLineRunner接口,第二种是实现ApplicationRunner接口第三种是使用注解:@PostConstruct1、CommandLineRunner1、CommandLineRunner执行的时间节点是在Application完成初始化工作之后。2、CommandLin