mwyking 2016-04-05 11:41 采纳率: 0%
浏览 5397

spring @Scheduled 定时任务,启动服务后,没触发定时任方法,不知什么原因引起

spring @Scheduled 定时任务,启动服务后,没触发定时任方法,不知什么原因引起,请大家指引

job类如下:

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));  
}  

}

配置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" />

  • 写回答

1条回答

  • 君莫傲 博客专家认证 2016-04-06 00:27
    关注

    既然是定时任务,为什么我没有看到你的定时时间呢?
    如果定时任务不能执行的话,你可以手动执行以下,看看能否执行!

    评论

报告相同问题?

悬赏问题

  • ¥15 HFSS 中的 H 场图与 MATLAB 中绘制的 B1 场 部分对应不上
  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?