`
dowsam
  • 浏览: 1130 次
  • 性别: Icon_minigender_1
  • 来自: 福建
最近访客 更多访客>>
文章分类
社区版块
存档分类
最新评论

spring与quartz 整合报错

阅读更多

帮忙看看这个是什么问题,谢谢

public class MyTaskService {

    public void run(){
        System.out.println("任务开始了!");
    }
}

 

applicationContext.xml:

<?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: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">

    <!--dataSource数据源-->
    <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource">
        <property name="driverClassName" value="oracle.jdbc.driver.OracleDriver"/>
        <property name="url" value="jdbc:oracle:thin:@192.168.0.201:1521:osap"/>
        <property name="username" value="webadmin"/>
        <property name="password" value="123456"/>
    </bean>

    <!--配置sessin工厂-->
    <bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
        <property name="dataSource">
            <ref local="dataSource" />
        </property>
        <property name="hibernateProperties">
            <props>
                <prop key="hibernate.dialect">org.hibernate.dialect.Oracle9Dialect</prop>
                <!-- 设置二级缓冲  -->
                <prop key="hibernate.cache.provider_class">
                    org.hibernate.cache.EhCacheProvider
                </prop>
                <!-- 设置二级缓冲,打开查询缓冲	  -->
                <prop key="hibernate.cache.use_query_cache">true</prop>
                <!-- 设置显示Hibernate操作的SQL语句  -->
                <prop key="hibernate.show_sql">true</prop>
            </props>
        </property>
        <property name="mappingDirectoryLocations">
            <list>
                <value>
                    classpath:/com/solex/sysmanage/model/config
                </value>
            </list>
        </property>
    </bean>


    <!--给DAO注入sessionFactory-->
    <bean id="dao" class="com.solex.sysmanage.dao.impl.BaseDaoImpl">
        <property name="sessionFactory">
            <ref local="sessionFactory"/>
        </property>
    </bean>


    <!--基础的服务类-->
    <bean id="baseDao" class="com.solex.sysmanage.service.impl.BaseServiceImpl">
        <property name="baseDao">
            <ref local="dao"/>
        </property>
    </bean>

   <!--自定义服务类-->
    <bean id="manageService" class="com.solex.sysmanage.service.impl.ManageServiceImpl">
        <property name="baseDao">
            <ref local="dao" />
        </property>
    </bean>

    <!--给interceptor注入事务-->
    <bean id="interceptor" class="com.solex.sysmanage.web.LoginInterceptor">
        <property name="manageService">
            <ref local="manageService" />
        </property>
    </bean>


    <!-- 配置事务管理器 -->
    <bean id="transactionManager"
          class="org.springframework.orm.hibernate3.HibernateTransactionManager">
        <property name="sessionFactory">
            <ref local="sessionFactory"/>
        </property>
    </bean>

    <!--监听器的test-->
    <bean id="myTask" class="com.solex.sysmanage.service.impl.MyTaskService">

    </bean>

    <bean id="scheduledReportJobDetail" class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">
        <property name="targetObject">
            <ref bean="myTask" />
        </property>
        <property name="targetMethod">
            <value>run</value>
        </property>
    </bean>

    <bean id="cronReportTrigger" class="org.springframework.scheduling.quartz.CronTriggerBean">
        <property name="jobDetail">
            <ref bean="scheduledReportJobDetail" />
        </property>
        <property name="cronExpression">
            <value>0 * * * *</value>
        </property>
    </bean>

    <bean id="schedulerFactoryBean" class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
        <property name="triggers">
            <list>
                <ref bean="cronReportTrigger" />
            </list>
        </property>
    </bean>

    <!-- 配置事务特性 ,配置add、delete和update开始的方法,事务传播特性为required-->
    <tx:advice id="txAdvice" transaction-manager="transactionManager">
        <tx:attributes>
            <tx:method name="insert*" propagation="REQUIRED"/>
            <tx:method name="save*" propagation="REQUIRED"/>
            <tx:method name="delete*" propagation="REQUIRED"/>
            <tx:method name="update*" propagation="REQUIRED"/>
            <tx:method name="*" read-only="true"/>
        </tx:attributes>
    </tx:advice>

    <!-- 配置那些类的方法进行事务管理,当前cn.com.jobedu.oa.service包中的子包、类中所有方法需要,还需要参考tx:advice的设置 -->
    <aop:config>
        <aop:pointcut id="allManagerMethod"
                      expression="execution (* com.solex.sysmanage.service.*.*(..))"/>
        <aop:advisor advice-ref="txAdvice"
                     pointcut-ref="allManagerMethod"/>
    </aop:config>


</beans>

  

 

 

报告代码:

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'cronReportTrigger' defined in class path resource [applicationContext.xml]: Error setting property values; nested exception is org.springframework.beans.PropertyBatchUpdateException; nested PropertyAccessExceptions (1) are:
PropertyAccessException 1: org.springframework.beans.MethodInvocationException: Property 'cronExpression' threw exception; nested exception is java.text.ParseException: Unexpected end of expression.
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1277)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1008)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:470)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409)
	at java.security.AccessController.doPrivileged(Native Method)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:380)
	at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:264)
	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:220)
	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:261)
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:185)
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:164)
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:429)
	at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:729)
	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:381)
	at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:255)
	at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:199)
	at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:45)
	at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3843)
	at org.apache.catalina.core.StandardContext.start(StandardContext.java:4342)
	at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:791)
	at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:771)
	at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:525)
	at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:627)
	at org.apache.catalina.startup.HostConfig.deployDescriptors(HostConfig.java:553)
	at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:488)
	at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1149)
	at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:311)
	at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:117)
	at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053)
	at org.apache.catalina.core.StandardHost.start(StandardHost.java:719)
	at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
	at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
	at org.apache.catalina.core.StandardService.start(StandardService.java:516)
	at org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
	at org.apache.catalina.startup.Catalina.start(Catalina.java:578)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:597)
	at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288)
	at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)
Caused by: org.springframework.beans.PropertyBatchUpdateException; nested PropertyAccessExceptions (1) are:
PropertyAccessException 1: org.springframework.beans.MethodInvocationException: Property 'cronExpression' threw exception; nested exception is java.text.ParseException: Unexpected end of expression.
	at org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:104)
	at org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:59)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1274)
	... 40 more

 

分享到:
评论

相关推荐

    Spring3.2.3+Quartz2.2 整合配置

    本篇文章将详细介绍如何将Spring 3.2.3版本与Quartz 2.2版本进行整合配置,以便在Spring应用中实现灵活的定时任务管理。 首先,集成Quartz到Spring项目中,我们需要在项目的`pom.xml`或`build.gradle`文件中添加...

    spring之quartz例子

    spring之quartz例子,与oracle整合,不过spring中的MethodInvokingJobDetailFactoryBean方法在存数据库时序列化有bug,在本例子中,使用了修复后的MethodInvokingJobDetailFactoryBean方法,避免了因序列化而报错。

    quartz.*整合struts2、spring一个的demo

    这个"quartz.*整合struts2、spring一个的demo"示例旨在演示如何将这三个组件集成到一起,实现一个完整的任务调度系统。 首先,我们来看Quartz的集成。Quartz的核心概念包括Job(工作)、Trigger(触发器)和...

    Quartz--JAVA定时任务\Java应用:Java调度任务和Spring Quartz (1)

    通过Spring与Quartz的整合,可以轻松地在Spring应用中管理定时任务,提高代码的可维护性。 总结来说,Quartz是Java中强大的定时任务库,通过它我们可以方便地创建和管理复杂的任务调度,包括但不限于在特定时间点...

    Springboot整合quartz产生错误及解决方案

    在Spring Boot应用中整合Quartz作为任务调度框架是常见的需求,用于执行周期性的后台任务。然而,在实际操作中,可能会遇到一些错误,如"ObjectAlreadyExistsException",这通常是由于Quartz在尝试创建已存在的Job时...

    quartz-all-1.6.6.jar

    与Spring整合必须使用Quartz1.8.x及以下版本 否则报错 java.lang.IncompatibleClassChangeError: class org.springframework.scheduling.quartz.CronTriggerBean has interface org.quartz.CronTrigger as super ...

    SSM框架整合示例

    同时,可以扩展其他功能,如安全控制(Spring Security)、任务调度(Quartz)等。 理解并熟练掌握SSM框架的整合,对提升Java Web开发效率和项目质量具有重要意义。通过实践这个示例项目,开发者能够深入学习每个...

    springboot+mybatis+druid+jsp+bootstrap实现后台权限管理系统源码.zip

    项目基于jdk1.8整合了springboot+mvc+mybatis(通用mapper)+druid+jsp+bootstrap等技术,springboot+Listener(监听器),Filter(过滤器),Interceptor(拦截器),Servlet,springmvc静态资源,文件上传下载,多数据源切换,缓存...

    单点登录源码

    Quartz | 作业调度框架 | [http://www.quartz-scheduler.org/](http://www.quartz-scheduler.org/) Ehcache | 进程内缓存框架 | [http://www.ehcache.org/](http://www.ehcache.org/) ActiveMQ | 消息队列 | ...

Global site tag (gtag.js) - Google Analytics