import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service; /**
* Created by chenguangjin on 2018/3/9.
*/
@Service
public class ScheduledTest { @Scheduled(cron = "0 0/1 * * * ?")
public void scheduledMethod(){
System.out.println("scheduled method start!");
} }

依赖:

    <properties>
<spring.version>4.3.6.RELEASE</spring.version>
</properties> <dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>${spring.version}</version>
</dependency>
</dependencies>

使用@Scheduled注解编写spring定时任务的更多相关文章

  1. 基于@Scheduled注解的Spring定时任务

    1.创建spring-task.xml 在xml文件中加入命名空间 <beans xmlns="http://www.springframework.org/schema/beans& ...

  2. 基于 @Scheduled 注解的 ----定时任务

    最常用的方法@Scheduled 注解表示起开定时任务 依赖 <dependencies> <dependency> <groupId>org.springfram ...

  3. 关于Spring定时任务(定时器)用法

    Spring定时任务的几种实现 Spring定时任务的几种实现 一.分类 从实现的技术上来分类,目前主要有三种技术(或者说有三种产品): 从作业类的继承方式来讲,可以分为两类: 从任务调度的触发时机来 ...

  4. @Scheduled注解

    1 概述 @Scheduled注解是spring boot提供的用于定时任务控制的注解,主要用于控制任务在某个指定时间执行,或者每隔一段时间执行.注意需要配合@EnableScheduling使用,配 ...

  5. 使用轻量级Spring @Scheduled注解执行定时任务

    WEB项目中需要加入一个定时执行任务,可以使用Quartz来实现,由于项目就一个定时任务,所以想简单点,不用去配置那些Quartz的配置文件,所以就采用了Spring @Scheduled注解来实现了 ...

  6. Spring定时任务@Scheduled注解使用方式

    1.开篇 spring的@Scheduled定时任务相信大家都是十分熟悉.最近在使用过程中发现了一些问题,写篇文章,和大家分享一下.结论在最后,不想看冗长过程的小伙伴可以直接拉到最后看结论. 2.简单 ...

  7. Spring框架中的Quartz定时任务使用笔记(通过@Scheduled注解的方式实现)

    1.修改spring的xml配置信息 applicationContext.xml 三个部分内容 1.xmlns添加:xmlns:task="http://www.springframewo ...

  8. 使用spring提供的@Scheduled注解创建定时任务

    使用方法 操作非常简单,只要按如下几个步骤配置即可 1. 导入jar包或添加依赖,其实定时任务只需要spring-context即可,当然起服务还需要spring-web: 2. 编写定时任务类和方法 ...

  9. spring定时任务详解(@Scheduled注解)( 转 李秀才的博客 )

    在springMVC里使用spring的定时任务非常的简单,如下: (一)在xml里加入task的命名空间 xmlns:task="http://www.springframework.or ...

随机推荐

  1. Cryptography I 学习笔记 --- 零碎

    1. KDF(密钥推导函数,key derivation function),根据用户输入的一个初始密钥来生成一系列的后续密钥.可以使用PRF来生成 2. 可以用salt与slow hash func ...

  2. apache url rewrite问题

    apache RewriteEngine Your browser sent a request that this server could not understand http://www.ra ...

  3. Linux下创建和删除用户

    在Linux下创建用户和删除用户,必须在root用户下,如果你当前不是用根用户登录,你可以打开终端,输入"su root"命令,再输入根口令,就可以进入root用户模式下,如下所示 ...

  4. Jsp2.0自定义标签(第三天)——EL表达式的使用

    1.提出问题: 我们经常会看到这样的jsp页面代码: 浏览器显示: 为什么会在页面输出:Hello World  ,${per}究竟是如何找到“Hello World”的呢? 2.分析问题: 要想解决 ...

  5. python 浮点数保留小数

    http://www.cnblogs.com/Raymon-Geng/p/5784290.html 这里有三种方法, round(a,2) '%.2f' % a Decimal('5.000').qu ...

  6. TensorFlow笔记二:线性回归预测(Linear Regression)

    代码: import tensorflow as tf import numpy as np import xlrd import matplotlib.pyplot as plt DATA_FILE ...

  7. OpenReadWithHttps

    ///<summary>///采用https协议访问网络///</summary>///<param name="URL">url地址</ ...

  8. 【Android】内存卡图片读取器,图库app

    上一篇<[Android]读取sdcard卡上的全部图片而且显示,读取的过程有进度条显示>(点击打开链接)在真机上測试非常有问题.常常遇到内存溢出.卡死的情况.由于如今真机上的内存上,2G ...

  9. swiper-demo1

    <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title> ...

  10. IE67实现inline-block布局

    inline-block可以定义元素为行内块级元素,即既具有行内元素同占一行的特点,又具有块级元素的box模型.但是IE67和其他浏览器的支持差别比较大: 1.行内元素使用inline-block变成 ...