SpringBoot如何​​​​​​​定制项目启动过程?

有时我们需要在项目启动时定制一些额外的功能,比如加载一些系统参数,完成初始化,以及预热本地缓存。我们应该怎么做呢? 好消息是,SpringBoot提供了。 CommandLineRunner ApplicationRunner 这两个接口可以帮助我们实现上述要求。 它们的用法很简单,以ApplicationRunner接口为例: @Component public class TestRunner implements ApplicationRunner {     @Autowired     private LoadDataService loa..

相关推荐 去reddit讨论