spring 使用注解启动定时器不执行

spring 使用注解启动定时器不执行

spring 配置: applicationContext.xml 

配置: 
Java代码   收藏代码
  1. <task:executor id="executor" pool-size="5" />    
  2.  <task:scheduler id="scheduler" pool-size="10" />    
  3.  <task:annotation-driven executor="executor" scheduler="scheduler" />   

命名空间: 
Java代码   收藏代码
  1. <beans xmlns="http://www.springframework.org/schema/beans"  
  2.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"   
  3.        xmlns:context="http://www.springframework.org/schema/context"   
  4.        xmlns:tx="http://www.springframework.org/schema/tx"  
  5.        xmlns:security="http://www.springframework.org/schema/security"  
  6.        xmlns:amq="http://activemq.apache.org/schema/core"   
  7.        xmlns:jee="http://www.springframework.org/schema/jee"  
  8.        xmlns:task="http://www.springframework.org/schema/task"  
  9.        xsi:schemaLocation="  
  10. http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd  
  11. http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd  
  12. http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd   
  13. http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd  
  14. http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-2.0.1.xsd  
  15. http://activemq.apache.org/schema/core http://activemq.apache.org/schema/core/activemq-core.xsd  
  16. http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-2.0.xsd  
  17. http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task-3.0.xsd  
  18. " default-lazy-init="true">  



Java代码   收藏代码
  1. @Component  
  2. public class TestTask {  
  3.       
  4.     @Autowired  
  5.     private TestService testService;  
  6.       
  7.     @Scheduled(fixedDelay=5000)  
  8.     public void notifiy(){  
  9.         System.err.println("------------==========-------------");  
  10.           
  11.     }  
  12. }  

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值