您的位置:首页 > 编程语言 > Java开发

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

2013-08-05 21:51 399 查看
spring 使用注解启动定时器不执行

spring 配置: applicationContext.xml 

配置: 

Java代码  


<task:executor id="executor" pool-size="5" />    

 <task:scheduler id="scheduler" pool-size="10" />    

 <task:annotation-driven executor="executor" scheduler="scheduler" />   

命名空间: 

Java代码  


<beans xmlns="http://www.springframework.org/schema/beans"  

       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"   

       xmlns:context="http://www.springframework.org/schema/context"   

       xmlns:tx="http://www.springframework.org/schema/tx"  

       xmlns:security="http://www.springframework.org/schema/security"  

       xmlns:amq="http://activemq.apache.org/schema/core"   

       xmlns:jee="http://www.springframework.org/schema/jee"  

       xmlns:task="http://www.springframework.org/schema/task"  

       xsi:schemaLocation="  
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd   http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd   http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd    http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd   http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-2.0.1.xsd   http://activemq.apache.org/schema/core http://activemq.apache.org/schema/core/activemq-core.xsd   http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-2.0.xsd   http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task-3.0.xsd  
" default-lazy-init="true">  

Java代码  


@Component  

public class TestTask {  

      

    @Autowired  

    private TestService testService;  

      

    @Scheduled(fixedDelay=5000)  

    public void notifiy(){  

        System.err.println("------------==========-------------");  

          

    }  

}  
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  Spring