【JAVA笔记】spring3.x配置--每天23:30分执行任务 & log4j.properties的配置

任务:每天23:30执行某个任务。老总让用spring quartz做╮(╯_╰)╭


项目名称:CompactAndExtract


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"
	xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">

	<bean name="biz" class="com.*.biz.QuartzBiz"></bean>
  <bean id="methodInvokingJobDetail" class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">
       <property name="targetObject">
           <ref bean="biz" />
       </property>
       <property name="targetMethod">
           <value>doSth</value>
       </property>
     </bean>
    
     <bean id="cronTrigger" class="org.springframework.scheduling.quartz.CronTriggerBean">
       <property name="jobDetail">
           <ref bean="methodInvokingJobDetail" />
       </property>
       <!-- 每天23:30触发 -->
       <property name="cronExpression">
           <!-- <value>0 30 23 * * ?</value> -->
           <value>0 30 23 * * ?</value>
       </property>
     </bean>
    
  <bean class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
       <property name="triggers">
           <list>
              <ref local="cronTrigger" />
           </list>
       </property>
    </bean>
</beans>

我是照着这篇博文改的:http://www.cnblogs.com/kay/archive/2007/11/02/947372.html

灰常简洁明了,感激不禁~~\(≧▽≦)/~


顺便记一下log4j.properties的配置:

### direct log messages to stdout ###
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.Target=System.out
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L - %m%n
### root logger option ###
log4j.rootLogger=warn, stdout
### Hibernate logging options ###
log4j.logger.net.sf.hibernate=info
### log JDBC bind parameters ###
log4j.logger.net.sf.hibernate.type=info
### log PreparedStatement cache activity ###
log4j.logger.net.sf.hibernate.ps.PreparedStatementCache=info

©️2020 CSDN 皮肤主题: 大白 设计师: CSDN官方博客 返回首页
实付0元
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、C币套餐、付费专栏及课程。

余额充值