大家都知道spring有一个quartz可以实现,那么现在我已经把配置文件给配置好了.
<bean name="updateMarket" class="cn.market.quartz.IntegralUpdate"
singleton="false">
<property name="mgr1">
<ref bean="userManager" />
</property>
</bean>
<bean id="jobDetaill"
class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">
<property name="targetObject" ref="updateMarket" />
<property name="targetMethod" value="marketIntegral" />
<property name="concurrent" value="false" />
</bean>
<bean id="cronTriggers"
class="org.springframework.scheduling.quartz.CronTriggerBean">
<property name="jobDetail" ref="jobDetaill" />
<property name="cronExpression" value="0 20 00 * * ? *"/>
</bean>
以下是配置userManager;
<bean id="userManager" parent="baseTxProxy">
<property name="target">
<bean
class="cn.market.service.impl.MarketUserManagerImpl">
<property name="userDaoHibernate" ref="userDao" />
<property name="userLogDaoHibernate" ref="loginLogDao" />
</bean>
</property>
</bean>
其中mgr1为实现接口的一个成员,userManager为操作userManager的ID.,marketIntegral代表要执行的方法,"0 20 00 * * ? *"/表示每天晚上自动运行
附代码:
public class IntegralUpdate {
private IMarketUserManager mgr1;
public void marketIntegral(){
mgr1.updateMarketUserSql("update Marketuser set Integral=Integral+30 where marketid='4028809911c5847b0111c58c3a9e0002'");
}
public void setMgr1(IMarketUserManager mgr1) {
this.mgr1 = mgr1;
}
}
以上程序是实现每天给用户加30分的操作.
有问题可以留言评论,...
青菜猫(孙宇)
posted on 2007-10-19 21:51
青菜猫(孙宇) 阅读(1948)
评论(0) 编辑 收藏