最佳答案
我想在spring-boot应用程序开始监视目录更改之后运行代码。
我已经尝试运行一个新线程,但@Autowired
服务尚未设置在这一点上。
我已经能够找到ApplicationPreparedEvent
,它在设置@Autowired
注释之前触发。理想情况下,我希望事件在应用程序准备好处理http请求时触发。
是否有更好的事件可以使用,或者在应用程序在spring-boot中激活后运行代码的更好方式?