前言我们在WEB项目启动之后有时候还会做点其它的东西(比如,导入数据脚本),下面就说说spring-boot里怎么在程序启动后加入自己要执行的东西方法如下:新建一个类:BeforeStartup.java@Configurationpubl
前言
我们在WEB项目启动之后有时候还会做点其它的东西(比如,导入数据脚本),下面就说说spring-boot里怎么在程序启动后加入自己要执行的东西
方法如下:
新建一个类:BeforeStartup.java
@Configurationpublic class BeforeStartup implements ApplicationListener<ContextRefreshedEvent> { @Autowired private InitDB initDB; @Override public void onApplicationEvent(ContextRefreshedEvent contextRefreshedEvent) { initDB.createUser(); }}
--结束END--
本文标题: spring boot在启动项目之后执行的实现方法
本文链接: https://www.lsjlt.com/news/222757.html(转载时请注明来源链接)
有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341
下载Word文档到电脑,方便收藏和打印~
2024-05-05
2024-05-05
2024-05-05
2024-05-05
2024-05-05
2024-05-05
2024-05-05
2024-05-05
2024-05-05
2024-05-05
回答
回答
回答
回答
回答
回答
回答
回答
回答
回答
0