1.因为我们在下一章要讲到jdbc的初始化,所以这一章,我们得先讲如何初始化springboot
首先,我们要定义一个类
public class DBConfig implements ApplicationListener<ContextRefreshedEvent> {
private final Logger logger = LoggerFactory.getLogger(this.getClass());
@Override
public void onApplicationEvent(ContextRefreshedEvent event) {
System.out.println("服务器启动配置");
}
}
2.我们需要在函数入口
这个类下面进行bean的注入
@Bean
public DBConfig applicationStartListener(){
return new DBConfig();
}
这样我们就完成了springboot初始化函数的调用。
下一章我们将讲怎么初始化jdbc