Why isn't Spring running my @Scheduled method?

前端 未结 8 1618
天涯浪人
天涯浪人 2020-12-29 03:18

I\'m a bit befuddled because I\'m trying use use @Scheduled annotations, but Spring doesn\'t seem to be finding my methods. The end result is that, none of my m

相关标签:
8条回答
  • 2020-12-29 04:06

    I solved by adding both:

    xmlns:task="http://www.springframework.org/schema/task"
    xmlns:tx="http://www.springframework.org/schema/tx"
    

    then:

    <!-- TASK -->
        <task:scheduler id="searchScheduler" pool-size="1"/>
        <task:executor id="searchExecutor" pool-size="1"/>
        <task:annotation-driven executor="searchExecutor"  scheduler="searchScheduler"/>
    

    and in the bootom of my applicationContext.xml:

    <tx:annotation-driven/>
    
    0 讨论(0)
  • 2020-12-29 04:18

    I Solve it by remove use-default-filters="false" in context:component-scan my old config is

     <context:component-scan base-package="com.XXXx" use-default-filters="false">
            <context:include-filter type="annotation" expression="org.springframework.stereotype.Controller"/>
        </context:component-scan>
    

    my spring version 3.2.3

    0 讨论(0)
提交回复
热议问题