CommandLineRunner ApplicationRunner

pastaCoder·2022년 10월 26일
0

CommandLineRunner, ApplicationRunner둘다 어플리케이션 구동시점에 실행됨.
필자의 경우 testcase에서 data를 init해주기위해 사용했음.
두 인터페이서의 파라미터가다름

CommandLineRunner String을 인자로 받고 ApplicationRunner는 ApplicationArguments 인터페이스를 인자로 받음

CommandLineRunner, ApplicationRunner의 실행순서가 문제가 되는경우

실행순서는 Order 어노테이션으로 명시해주면 됨

@Order(1)
@Component
public class DemoCommandLineRunner implements CommandLineRunner { ...

@Order(2)
@Component
public class DemoApplicationRunner implements ApplicationRunner { ...

0개의 댓글