Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/spring-boot/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Spring 原型bean上的计划注释方法_Spring_Spring Boot_Spring Scheduled - Fatal编程技术网

Spring 原型bean上的计划注释方法

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的一个实例,我希望每个实例都启动定

我有一个范围为“prototype”(不是singleton)的bean,它带有@Scheduled注释方法

@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!