반응형
commandlinerunner
-
[spring] spring boot 초기 구동 시키기 및 초기화 코드Spring/spring boot 및 기타 2020. 8. 29. 16:34
스프링 어플리케이션을 시작할때 어플리케이션이 뜰때 초기 구동시켜줘야하는 코드들이 있을 수 있다. 이 때 해결 방법이 CommandLineRunner, ApplicationRunner, @EventListener 방법으로 초기 실행코드를 구현 할 수 있다. @Component //component scanning에 의한 방식으로 빈을 등록하는 방법 public class MyCLRunner implements CommandLineRunner { @Override public void run(String... args) throws Exception { System.out.println("CommandLineRunner Args: " + Arrays.toString(args)); } } 또는 @Bean 으로..