springboot项目如果想实现启动后自动运行某个方法,慎用@PostConstruct注解,最好老老实实实现ApplicationRunner,然后重写run方法,不然会造成某些bean还未注入spring,方法却已运行,造成某些资源无法正常被调用。
@PostConstruct
最新推荐文章于 2025-07-04 20:04:08 发布
springboot项目如果想实现启动后自动运行某个方法,慎用@PostConstruct注解,最好老老实实实现ApplicationRunner,然后重写run方法,不然会造成某些bean还未注入spring,方法却已运行,造成某些资源无法正常被调用。