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

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 求解 yolo算法问题
  • ¥15 虚拟机打包apk出现错误
  • ¥30 最小化遗憾贪心算法上界
  • ¥15 用visual studi code完成html页面
  • ¥15 聚类分析或者python进行数据分析
  • ¥15 逻辑谓词和消解原理的运用
  • ¥15 三菱伺服电机按启动按钮有使能但不动作
  • ¥15 js,页面2返回页面1时定位进入的设备
  • ¥50 导入文件到网吧的电脑并且在重启之后不会被恢复
  • ¥15 (希望可以解决问题)ma和mb文件无法正常打开,打开后是空白,但是有正常内存占用,但可以在打开Maya应用程序后打开场景ma和mb格式。