当前位置:   article > 正文

ssm(spring+springMVC+Mybatis)框架 集成Quartz(定时任务框架)_ssm可以集成什么集群定时任务

ssm可以集成什么集群定时任务

1、ssm框架基础jar 包

  1. aopalliance.jar
  2. aspectjrt.jar
  3. aspectjweaver.jar
  4. commons-beanutils-1.9.2.jar
  5. commons-codec-1.9.jar
  6. commons-collections-3.2.1.jar
  7. commons-dbcp-1.4.jar
  8. commons-fileupload-1.3.1.jar
  9. commons-io-2.4.jar
  10. commons-lang-2.6.jar
  11. commons-logging-1.2.jar
  12. commons-net-3.1.jar
  13. commons-pool-1.6.jar
  14. commons-pool2-2.2.jar
  15. druid-1.0.9.jar
  16. fastjson-1.1.39.jar
  17. freemarker-2.3.19.jar
  18. hamcrest-core-1.3.jar
  19. jackson-all-1.9.5.jar
  20. jboss-logging-3.1.0.CR2.jar
  21. jettison-1.0.1.jar
  22. jstl-1.1.2.jar
  23. junit-4.11.jar
  24. log4j-1.2.17.jar
  25. log4j-over-slf4j-1.7.7.jar
  26. mybatis-3.2.6.jar
  27. mybatis-spring-1.2.2.jar
  28. mysql-connector-java-5.1.30-bin.jar
  29. servlet-api.jar
  30. slf4j-api-1.7.7.jar
  31. slf4j-ext-1.7.7.jar
  32. spring-aop-4.0.2.RELEASE.jar
  33. spring-aspects-4.0.2.RELEASE.jar
  34. spring-beans-4.0.2.RELEASE.jar
  35. spring-context-4.0.2.RELEASE.jar
  36. spring-context-support-4.0.2.RELEASE.jar
  37. spring-core-4.0.2.RELEASE.jar
  38. spring-expression-4.0.2.RELEASE.jar
  39. spring-jdbc-4.0.2.RELEASE.jar
  40. spring-oxm-4.0.2.RELEASE.jar
  41. spring-test-4.0.2.RELEASE.jar
  42. spring-tx-4.0.2.RELEASE.jar
  43. spring-web-4.0.4.RELEASE.jar
  44. spring-webmvc-4.0.2.RELEASE.jar
  45. standard-1.1.2.jar

2、quartz 定时任务框架关联jar包

quartz-1.8.5.jar


3、quartz 定时任务实现类

  1. package com.wlsq.oauth.quartz;
  2. import java.util.Date;
  3. public class SpringQtz {
  4. private static int counter = 0;
  5. protected void execute() {
  6. long ms = System.currentTimeMillis();
  7. System.out.println("\t\t" + new Date(ms));
  8. System.out.println("(" + counter++ + ")");
  9. }
  10. }

4、相关配置文件

  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <beans xmlns="http://www.springframework.org/schema/beans"
  3. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
  4. xmlns:context="http://www.springframework.org/schema/context"
  5. xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:tx="http://www.springframework.org/schema/tx"
  6. xmlns:aop="http://www.springframework.org/schema/aop"
  7. xsi:schemaLocation="http://www.springframework.org/schema/beans
  8. http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
  9. http://www.springframework.org/schema/context
  10. http://www.springframework.org/schema/context/spring-context-3.1.xsd
  11. http://www.springframework.org/schema/tx
  12. http://www.springframework.org/schema/tx/spring-tx-3.1.xsd
  13. http://www.springframework.org/schema/mvc
  14. http://www.springframework.org/schema/mvc/spring-mvc-3.1.xsd
  15. http://www.springframework.org/schema/aop
  16. http://www.springframework.org/schema/aop/spring-aop-3.1.xsd">
  17. <!--运行时请将方式一注释掉! -->
  18. <!-- 方式二:使用MethodInvokingJobDetailFactoryBean,任务类可以不实现Job接口,通过targetMethod指定调用方法 -->
  19. <!-- 定义目标bean和bean中的方法 -->
  20. <bean id="SpringQtzJob" class="com.wlsq.oauth.quartz.SpringQtz" />
  21. <bean id="SpringQtzJobMethod"
  22. class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">
  23. <property name="targetObject">
  24. <ref bean="SpringQtzJob" />
  25. </property>
  26. <property name="targetMethod"> <!-- 要执行的方法名称 -->
  27. <value>execute</value>
  28. </property>
  29. </bean>
  30. <!-- ======================== 调度触发器 ======================== -->
  31. <bean id="CronTriggerBean" class="org.springframework.scheduling.quartz.CronTriggerBean">
  32. <property name="jobDetail" ref="SpringQtzJobMethod"></property>
  33. <property name="cronExpression" value="*/5 * * * * ?"></property>
  34. </bean>
  35. <!-- ======================== 调度工厂 ======================== -->
  36. <bean id="SpringJobSchedulerFactoryBean"
  37. class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
  38. <property name="triggers">
  39. <list>
  40. <ref bean="CronTriggerBean" />
  41. </list>
  42. </property>
  43. </bean>
  44. </beans>

其他文件请查考: ssm框架集成memcached服务器

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/weixin_40725706/article/detail/319719
推荐阅读
相关标签
  

闽ICP备14008679号