最近一直在使用JSF+Hibernate+Spring的配置进行项目二期的重构与开发,并采用了注解的方式,确实减少了很大的工作量。
但目前碰到一个问题,就是需要在其中使用调度程序,每天执行一些调度处理。
之前一期项目中使用了XML配置方式,调度能正常运行,而现在采用注解后就不行了。
代码如下:
[code="java"]
/**
- 报表调度器
- @author angeltears 2009-11-22
-
*/
public class ReportScheduler {
protected Logger logger = LoggerFactory.getLogger(ReportScheduler.class);private static final int SIZE_PER_TIME = 5000;
private ReportCatalogBS reportCatalogBS;
private RptModifyIntBS rptModifyIntBS;
public void doFromModify2MakeJob() {
......
}public void doSummaryJob() { ...... }
}
[/code]
此类用于执行调度,方法doFromModify2MakeJob和doSummaryJob都是调度执行的方法。它们在不同的时间点分别执行。
XML配置文件如下:
[code="java"]
<?xml version="1.0" encoding="UTF-8"?>
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
xmlns:aop="http://www.springframework.org/schema/aop" xmlns:context="http://www.springframework.org/schema/context"
xmlns:jee="http://www.springframework.org/schema/jee" xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd
http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-2.5.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd"
default-lazy-init="true">class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<!-- 标准配置 -->
classpath*:/application.properties
<!-- 本地开发环境配置 -->
<!-- value>classpath*:/application.local.properties
<!-- 服务器生产环境配置 -->
<!-- file:/var/myapp/application.server.properties -->
p:driverClassName="${jdbc.driverClassName}" p:url="${jdbc.url}"
p:username="${jdbc.username}" p:password="${jdbc.password}"
p:initialSize="5" p:maxActive="100" p:maxIdle="30" p:maxWait="1000"
p:poolPreparedStatements="true" p:defaultAutoCommit="false" />class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean"
p:dataSource-ref="dataSource">
${hibernate.dialect}
${hibernate.show_sql}
${hibernate.format_sql}
${hibernate.generate_statistics}
${hibernate.cache.use_query_cache}
${hibernate.cache.use_second_level_cache}
${hibernate.use_sql_comments}
${hibernate.jdbc.fetch_size}
${hibernate.jdbc.batch_size}
${hibernate.query.factory_class}
${hibernate.cache.provider_class}
${hibernate.ehcache_config_file}
value="com.fenet.gddb.cds.model.*,com.fenet.gddb.cds.model.*.*,com.fenet.gddb.cds.model.*.*.*" />class="org.springframework.orm.hibernate3.HibernateTransactionManager">
class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">
<!-- 每天18点10分到20点执行,每隔1分钟执行一次 -->
<!-- 每月的最后一天18点10分开始到20点之间,每隔1分钟运行一次的执行 -->
<!--property name="cronExpression" value="0 10/1 18,20 L * ?" /-->
class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">
<!-- 每天0点至6点执行,每隔30分钟运行一次 -->
[/code]
Web.xml中的ContextLoaderListener和contextConfigLocation都配置了,但在指定的时间内,却一点反应也没有,请各路英雄解救下!谢谢了
[b]问题补充:[/b]
我明天试试,谢谢!
另外,spring封装quartz类SchedulerFactoryBean不能使用惰加载,和 lazy-init="true" > 是冲突的吧?不能使用惰加载不是应该设置为lazy-init="false"吗