2017-04-12 3 views
3

우리는 스프링 프로세스를 백그라운드 프로세스로 실행하므로 시작 로그에 액세스 할 수 없으므로 부트 시작 프로세스가 완료된 후에 알 수있는 방법이 있습니까?스프링 부트 시작 리스너

답변

3

봄 부팅 프로세스가 시작된 후 일부 코드를 실행하도록 선택할 수 있습니다. 시작이 완료되면 시작 완료 알림이 전송 될 수 있습니다.

@SpringBootApplication 
@Component 
public class Application implements CommandLineRunner { 

    public static void main(String[] args) { 
     SpringApplication.run(Application.class, args); 
    } 

    @Override 
    public void run(String... arg0) throws Exception { 
     // You can write your code here. 
     // This code will be executed after Spring Boot Startup completed. 

    } 
} 

위의 그림과 같이 CommandLineRunner를 구현하기 만하면됩니다.

http://docs.spring.io/spring-boot/docs/1.5.2.RELEASE/reference/htmlsingle/#boot-features-command-line-runner

관련 문제