1.  spring  + quartz  启动 停止 添加job 功能 

         一 maven添加quartz  的jar   

java 框架-spring 整合 quartz  框架 service层 注入不了job 类

    二 代码区    

   applicationContext.xml  导入 quartz.xml   <import resource="classpath:spring/quartz.xml"/>

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:context="http://www.springframework.org/schema/context"
    xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:aop="http://www.springframework.org/schema/aop"
    xmlns:tx="http://www.springframework.org/schema/tx" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:util="http://www.springframework.org/schema/util"
    xsi:schemaLocation="http://www.springframework.org/schema/beans 
        http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
        http://www.springframework.org/schema/aop 
        http://www.springframework.org/schema/aop/spring-aop-4.0.xsd
        http://www.springframework.org/schema/context
        http://www.springframework.org/schema/context/spring-context-4.0.xsd
        http://www.springframework.org/schema/mvc 
        http://www.springframework.org/schema/mvc/spring-mvc-4.0.xsd
        http://www.springframework.org/schema/tx 
        http://www.springframework.org/schema/tx/spring-tx-4.0.xsd
        http://www.springframework.org/schema/util
        http://www.springframework.org/schema/util/spring-util-4.0.xsd">
    
    
    <!-- 定时器 启动 停止  -->
    <bean >  
       <!-- 定义jobfactor是解决service层 注入不了job 里面问题 -->
      <property name="jobFactory" ref="jobFactory"></property>
      <property name="triggers">  
         <list>  
             <!-- <ref bean="cronTrigger" /> -->
         </list>  
      </property>  
    </bean>  
    <bean ></bean>
    <bean  >  
     <!--这个对象一定要注入,这样类才能进行管理,还有在类型要用get set方法,不然会报错。-->  
    <property name="scheduler" ref="startQuartzs" />  
    </bean>   
</beans>
quartz.xml

相关文章: