[springboot] Application service startup event listener

insert image description here

1. Introduction

Spring Boot provides two interfaces: CommandLineRunner and ApplicationRunner, which are used to do special processing when starting the application. These codes will be executed before the run() method of SpringApplication is completed. Compared with the Spring's ApplicationListener interface custom listener and Servlet's ServletContextListener listener introduced in the previous chapter. The advantage of using the two is that you can easily use the application startup parameters, and perform different initialization operations according to different parameters.

2. Commonly used places

Guess you like

Origin blog.csdn.net/hanxiaotongtong/article/details/122892736