CommandLineRunner或ApplicationRunner接口

前言

CommandLineRunner和ApplicationRunner接口是在容器启动成功后的最后一步回调。

CommandLineRunner接口

接口被用作将其加入spring容器中时执行其run方法,多个CommandLineRunner可以被同时执行在同一个spring上下文中并且捃顺序是以order注解的参数顺序一致。

ApplicationRunner接口

以上面接口的javadoc一样,区别在于接收的参数不一样。CommandLineRunner参数是最原始的参数,没有做任何处理。ApplicationRunner的参数是ApplicationArguments,是对原始参数做了进一步封装。

猜你喜欢

转载自blog.csdn.net/CHS007chs/article/details/84095997