首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >spring 定时任务的实现

spring 定时任务的实现

作者头像
用户1499526
发布2019-07-15 17:42:32
3360
发布2019-07-15 17:42:32
举报
文章被收录于专栏:简单的日记简单的日记

1.xml的配置文件中加入

xmlns:jdbc="http://www.springframework.org/schema/jdbc" xmlns:jee="http://www.springframework.org/schema/jee"

		http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task-3.1.xsd "

2.配置文件中加入扫描代码

    <!-- 任务调度器 -->
    <task:scheduler id="scheduler" pool-size="10"/>

    <!-- 任务执行器 -->
    <task:executor id="executor" pool-size="10"/>

    <!--开启注解调度支持 @Async @Scheduled-->
    <task:annotation-driven executor="executor" scheduler="scheduler" proxy-target-class="true"/>

3.类的注解

在类上面加上@compent注解,同时注意加入@Lazy(value=false).,才能运行

4.方法上面加入

@Scheduled(cron = "0/5 * * * * ?")
本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档