5 ways to make methods execute automatically when Springboot starts

5 ways to make methods execute automatically when Springboot starts

Prerequisite @Component on class

1. Implement ServletContextAware
2. Implement ServletContextListener
3. Implement ApplicationRunner
4.static static code block
5. Add @PostConstruct to the method

Guess you like

Origin blog.csdn.net/hsadfdsahfdsgfds/article/details/115366760