mwyking 2016-04-05 11:25 采纳率: 0%
浏览 5999

SPRING @Scheduled 定时任没执行

项目主要配置及代码如下,但是启动服务后,一直没执行这个方法,不知什么原因。请指点

package com.yl.reqPos;

import java.text.SimpleDateFormat;

import java.util.Date;

import org.springframework.context.annotation.Lazy;
import org.springframework.scheduling.annotation.Scheduled;

import org.springframework.stereotype.Component;
@Component
@Lazy(false)
public class Singer {

@Scheduled(cron  ="0/5 * * * * *")     //第二种方式  
    public void singing(){  
    Date date=new Date();  
    SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");  
    System.out.println(sdf.format(date));  
}  

}

applicationContext-jobs.xml配置:
<?xml version="1.0" encoding="UTF-8"?>
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:task="http://www.springframework.org/schema/task"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/task
http://www.springframework.org/schema/task/spring-task-3.2.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.2.xsd"
default-lazy-init="false">

<context:component-scan base-package="com.yl.reqPos.*" />



queue-capacity="500" rejection-policy="CALLER_RUNS" />

  • 写回答

2条回答

  • liuy_88 2016-04-07 04:27
    关注

    xml文件里面没有配置task吧

    评论

报告相同问题?

悬赏问题

  • ¥15 求差集那个函数有问题,有无佬可以解决
  • ¥15 【提问】基于Invest的水源涵养
  • ¥20 微信网友居然可以通过vx号找到我绑的手机号
  • ¥15 寻一个支付宝扫码远程授权登录的软件助手app
  • ¥15 解riccati方程组
  • ¥15 display:none;样式在嵌套结构中的已设置了display样式的元素上不起作用?
  • ¥15 使用rabbitMQ 消息队列作为url源进行多线程爬取时,总有几个url没有处理的问题。
  • ¥15 Ubuntu在安装序列比对软件STAR时出现报错如何解决
  • ¥50 树莓派安卓APK系统签名
  • ¥65 汇编语言除法溢出问题