主题:spring集成quartz,出现2次重复调用的问题

在项目中使用了quartz的任务调度,在本地测试的时候没有问题,只会调用1次部署到服务器上后,发现同一个任务,在相同的时间被调用了2次。本地环境 windowsXP ,spring2.5.1, sun的JDK 1.5, TOMCAT6 服务器环境 linux, jrockit-R27.3.1-jdk1.5.0_11, TOMCAT6 ,spring2.5.1 spring 配置文件:<bean id="targetJob" parent="txProxyTemplate" singleton="true"> <property name="target"> <bean class="com.service.impl.TaskServiceImpl"> <property name="baseHibernateDao"> <ref bean="baseHibernateDao"/> </property> </bean> </property> </bean> <bean id="jobDetail" class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean"> <property name="targetObject"> <ref bean="targetJob"/> </property> <property name="targetMethod"> <value>doJob</value> </property> <property name="concurrent" value="false" /> </bean> <bean id="jobTrigger" class="org.springframework.scheduling.quartz.CronTriggerBean""><property name="jobDetail"><ref bean="jobDetail"/></property><property name="cronExpression"> <value>0 0/10 * * * ?</value></property> </bean> <bean id="z" class="org.springframework.scheduling.quartz.SchedulerFactoryBean"><property name="triggers"><list><ref local="jobTrigger"/> </list></property> </bean> 查看了本地和服务器的LOG日志,打印到DEBUG 发现在服务器的日志中,下面的信息出现了2次,而在本地只有1次,这个是不是意味着 这个类被实例化了2次,所以才会出现同时调用2次的结果Creating shared instance of singleton bean 'jobDetail'Creating instance of bean 'jobDetail' with merged definition [Root bean: class [org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean]; scope=singleton; abstract=false; lazyInit=false; autowireCandidate=true; autowireMode=0; dependencyCheck=0; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null; defined in ServletContext resource [/WEB-INF/spring-service.xml]]Eagerly caching bean 'jobDetail' to allow for resolving potential circular referencesReturning cached instance of singleton bean 'targetJob' 希望大家能给出 解决方案 谢谢~~~~ 是TOMCAT配置出了问题 应大家要求,解释一下原因,是TOMCAT的配置文件server.xml配置不当引起的,请看下面这段配置就是错误的: <Host name="www.***.com" debug="0" appBase="webapps" unpackWARs="true" autoDeploy="true" xmlValidation="false" xmlNamespaceAware="false"> <Logger className="org.apache.catalina.logger.FileLogger" directory="logs" prefix="localhost_log." suffix=".txt" timestamp="true" /> <Context path="" docBase="/tomcat/webapps/***" debug="1" /> <Context path="/***2" docBase="/tomcat/webapps/***2" debug="1" /> </Host> 正确的配置如下 <Host name="www.***.com" debug="0" appBase="" unpackWARs="true" autoDeploy="true" xmlValidation="false" xmlNamespaceAware="false"> <Logger className="org.apache.catalina.logger.FileLogger" directory="logs" prefix="localhost_log." suffix=".txt" timestamp="true" /> <Context path="" docBase="/tomcat/webapps/***" debug="1" /> <Context path="/***2" docBase="/tomcat/webapps/***2" debug="1" /> </Host> 这两段的区别是第二段去除了appBase="webapps"中的webapps变成了appBase="",因为web应用程序都是放在webapps这个目录下的,如果不把“webapps“去掉,这里会调用一次quartz的任务调度,在接下来的“<Context path”中又会调用一次quartz的任务调度,所以就重复了2次
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值