我的问题原因 是 因为我的定时器配置在SpringMVC的配置文件applicationContext.xml中,而web.xml中ContextLoaderListener 和 DispatcherServlet都会扫描这个文件。故而项目启动时定时器会执行两次。

所以 只需要将 定时器配置单独 配成一个文件 applicationContext-task.xml,


spring 定时器 @Component 执行两次 问题解决
ContextLoaderListener 中加入扫描这个文件即可。

spring 定时器 @Component 执行两次 问题解决
spring 定时器 @Component 执行两次 问题解决
之前百度的其他答案 把appBase="webapps" 设置为appBase=""  对我的问题没用。


相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-12-08
  • 2021-07-17
  • 2022-01-09
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-07-02
  • 2021-09-11
  • 2021-11-01
  • 2021-11-27
  • 2022-02-18
相关资源
相似解决方案