Spring 原型bean上的计划注释方法
我有一个范围为“prototype”(不是singleton)的bean,它带有@Scheduled注释方法Spring 原型bean上的计划注释方法,spring,spring-boot,spring-scheduled,Spring,Spring Boot,Spring Scheduled,我有一个范围为“prototype”(不是singleton)的bean,它带有@Scheduled注释方法 @Component @Scope("prototype") public class TestManager { @Scheduled(fixedDelay = 5000) public void updateStatuses(){ log.info("Scheduled update"); } } 我在需要时调用bean的一个实例,我希望每个实例都启动定
@Component
@Scope("prototype")
public class TestManager {
@Scheduled(fixedDelay = 5000)
public void updateStatuses(){
log.info("Scheduled update");
}
}
我在需要时调用bean的一个实例,我希望每个实例都启动定时计时器。
调度器注释似乎不起作用,除非我删除范围并使bean再次成为单例
有好的解决办法吗?为什么不可能呢?如何获取TestManager bean实例?请参阅。在Spring4.3之前,基本上不支持任何其他的单例bean。非常感谢@M.Deinum!