spring @Scheduled不生效問題

1.spring版本 4.2.3.RELEASE

2.spring-config.xml配置

<context:component-scan base-package="com.xxx.mall.order.core" />

<task:scheduler id="scheduler" pool-size="20"/>
<task:annotation-driven scheduler="scheduler"/>
<aop:aspectj-autoproxy/>

3.測試類

/**
 * 押金打折
 * Created by xdc on 2019/1/15 18:05
 */
@Component
@EnableScheduling
@Lazy(false)
public class DepositDiscountTask {

    @Scheduled(cron = "0/3 * * * * ?")
    public void depositDiscount(){

        System.out.println(1);
    }
}

保證以上配置,可確保任務正常執行。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章