2017-04-12 94 views

回答

3

你可以选择在spring启动过程完成启动后执行一些代码,当启动完成时你可以发送关于启动完成的通知。

@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

相关问题