- @Component("apiWorker")
- public class ApiWorker
spring context 配置文件
- <?xml version="1.0" encoding="UTF-8"?>
- <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:task="http://www.springframework.org/schema/task"
- xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
- http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd
- http://www.springframework.org/schema/task
- http://www.springframework.org/schema/task/spring-task-3.0.xsd">
- <!--<bean id="javaMailSender" class="org.springframework.mail.javamail.JavaMailSenderImpl">-->
- <!--<property name="host" value="192.168.95.47"/>-->
- <!--<property name="username" value="sohuopen@xxxx.com"/>-->
- <!--<property name="defaultEncoding" value="utf-8"></property>-->
- <!--<property name="javaMailProperties">-->
- <!--<props>-->
- <!--<prop key="mail.debug">false</prop>-->
- <!--</props>-->
- <!--</property>-->
- <!--</bean>-->
- <context:component-scan base-package="com.sohu.twitter"/>
- <task:annotation-driven/>
- <import resource="classpath:open-dao-beans.xml"/>
- </beans>
task timer配置文件:
- <?xml version="1.0" encoding="UTF-8"?>
- <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:aop="http://www.springframework.org/schema/aop"
- xmlns:task="http://www.springframework.org/schema/task"
- xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
- http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-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/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
- http://www.springframework.org/schema/task
- http://www.springframework.org/schema/task/spring-task-3.0.xsd">
- <task:scheduled-tasks>
- <task:scheduled ref="apiWorker" method="doWork" cron="0 30 5 * * ?"/>
- </task:scheduled-tasks>
- <import resource="classpath:applicationContext-open-core.xml"/>
- </beans>