博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
quartz和spring结合后的使用,模仿型
阅读量:7173 次
发布时间:2019-06-29

本文共 3838 字,大约阅读时间需要 12 分钟。

没有真正理解内核,只是模仿使用。

用来定时检验是否为工作日。

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:context="http://www.springframework.org/schema/context" xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx=

"http://www.springframework.org/schema/tx"

xsi:schemaLocation=

"

http://www.springframework.org/schema/beans

http://www.springframework.org/schema/beans/spring-beans-3.0.xsd

http://www.springframework.org/schema/context

http://www.springframework.org/schema/context/spring-context-3.0.xsd

http://www.springframework.org/schema/tx

http://www.springframework.org/schema/tx/spring-tx-3.0.xsd

http://www.springframework.org/schema/aop

http://www.springframework.org/schema/aop/spring-aop-3.0.xsd"

>

 

<!-- cronTrigger extends QuartzJobBean,MyJob1 -->

<bean id="myJob1" class="org.springframework.scheduling.quartz.JobDetailBean"

>

<property name="jobClass" value="com.apple.sqm.dnwd.detect.delta.Detect"

/>

</bean>

<bean id="cronTrigger" class="org.springframework.scheduling.quartz.CronTriggerBean"

>

<property name="jobDetail" ref="myJob1"

/>

<property name="cronExpression" value="0/5 * * * * ?"

/>

</bean

>

<!-- set scheduler -->

<bean id="myScheduler" class="org.springframework.scheduling.quartz.SchedulerFactoryBean"

>

<property name="triggers"

>

<list

>

<ref bean="cronTrigger"

/>

</list

>

</property

>

<property name="quartzProperties"

>

<props

>

<prop key="org.quartz.threadPool.threadCount">50</prop

>

<prop key="org.quartz.scheduler.instanceId">AUTO</prop

>

</props

>

</property

>

</bean

>

</

 

beans>

 

 

 

commons-logging.properties

# \u6b64\u914d\u7f6e\u6587\u4ef6\u53ef\u4ee5\u7701\u7565,\u9ed8\u8ba4\u5c31\u662f\u4f7f\u7528\u7684log4j

# \u5fc5\u987b\u8981\u6709commons-logging-1.1.1.jar;

# commons-logging-adapters-1.1.1.jar,commons-logging-api-1.1.1.jar\u4e3a\u53ef\u9009

org.apache.commons.logging.Log=

org.apache.commons.logging.impl.Log4JLogger

 

log4j.rootLogger=

INFO,appender1

# org.springframework\u5305\u4e0b\u9762\u6240\u6709\u7684\u65e5\u5fd7\u8f93\u51fa\u7684\u7ea7\u522b\u8bbe\u4e3aDEBUG

log4j.logger.org.springframework=

INFO

# \u63a7\u5236\u53f0\u8f93\u51fa

log4j.appender.appender1=

org.apache.log4j.ConsoleAppender

log4j.appender.appender1.layout=

org.apache.log4j.PatternLayout

log4j.appender.appender1.layout.ConversionPattern=

%d{

yyyy-MM-dd HH:mm:ss:SSS}[%p]:

%m%n

# \u7acb\u5373\u8f93\u51fa

log4j.appender.appender1.immediateFlush=

true

 

 

package

com.apple.sqm.dnwd;

import

org.apache.commons.logging.Log;

import

org.apache.commons.logging.LogFactory;

import

org.springframework.context.support.ClassPathXmlApplicationContext;

 

public

classDNWDServer {

/**

*

@param

args

*/

private static Log log = LogFactory.getLog(DNWDServer.class);

public static void main(String[] args) throws Exception {

log.info("Detect non-working-day start");

new ClassPathXmlApplicationContext("applicationContext.xml");

}

}

package

com.apple.sqm.dnwd.detect;

import

org.apache.commons.logging.Log;

import

org.apache.commons.logging.LogFactory;

import

org.quartz.JobExecutionContext;

import

org.quartz.JobExecutionException;

import

org.springframework.scheduling.quartz.QuartzJobBean;

 

public

abstract class ADetect extends

QuartzJobBean {

Log

log = LogFactory.getLog(ADetect.class

);

protected void executeInternal(JobExecutionContext ctx) throws

JobExecutionException {

extractQuanlity();

}

public abstract void

extractQuanlity();

}

package

com.apple.sqm.dnwd.detect.delta;

import

org.apache.commons.logging.Log;

import

org.apache.commons.logging.LogFactory;

import

com.apple.sqm.dnwd.detect.ADetect;

 

 

public

class Detect extends

ADetect{

Log

log = LogFactory.getLog(Detect.class

);

@Override

public void

extractQuanlity() {

log.info("Hello,in detecting"

);

log.info(Detect.class

.getName());

}

}

转载地址:http://vlbzm.baihongyu.com/

你可能感兴趣的文章
通过NavMeshObstacle解决NavMesh防卡
查看>>
Current-sense monitor and MOSFET boost output current
查看>>
实验二 伸展树算法设计与实现
查看>>
kendo-ui表单验证
查看>>
ocp 1Z0-051 71-105题解析
查看>>
Web App之一
查看>>
linux less命令详解
查看>>
iOS MessagePack
查看>>
【转】Linux下的文本dos格式转Unix格式,去除^M符号
查看>>
怎样用OleDbDataAdapter来对数据库进行操作?
查看>>
查询sql执行速度
查看>>
Android中ExpandableListView控件基本使用
查看>>
关于软件架构师基本素质和职责【概念转摘】
查看>>
The message queue
查看>>
citrix协议ICA技术原理
查看>>
POJ1845:Sumdiv(求因子和+逆元+质因子分解)好题
查看>>
八大排序算法总结
查看>>
POJ 3211 Washing Clothes
查看>>
VS2010旗舰版安装图解
查看>>
无法识别的属性“targetFramework”。请注意属性名称区分大写和小写。错误解决的方法...
查看>>