Linux+httpd+mysql+php_网站服务器搭建_Lamp
2012-12-15 16:53
706 查看
需要引入quartz-all.jar,具体用法如下
Java代码:
package com.coalmine.desktop;
import java.text.SimpleDateFormat;
import java.util.Date;
public class QuartzJob {
public
void work() {
SimpleDateFormat
sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Date
date = new Date();
System.out.println(sdf.format(date)
+ " 执行Quartz定时器");
}
}
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:jee="http://www.springframework.org/schema/jee"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-2.0.xsd">
<!--
要调用的工作类 -->
<bean
id="quartzJob"
class="com.coalmine.desktop.QuartzJob"></bean>
<!--
定义调用对象和调用对象的方法 -->
<bean
id="jobtask"
class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">
<!--
调用的类 -->
<property
name="targetObject">
<ref
bean="quartzJob" />
</property>
<!--
调用类中的方法 -->
<property
name="targetMethod">
<value>work</value>
</property>
</bean>
<!--
定义触发时间 -->
<bean
id="doTime"
class="org.springframework.scheduling.quartz.CronTriggerBean">
<property
name="jobDetail">
<ref
bean="jobtask" />
</property>
<!--
cron表达式 -->
<property
name="cronExpression">
<!--
第 10秒
隔 5秒执行一次-->
<value>10/5
* * * * ?</value>
</property>
</bean>
<!--
总管理类 如果将lazy-init='false'那么容器启动就会执行调度程序 -->
<bean
id="startQuertz" lazy-init="false" autowire="no"
class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
<property
name="triggers">
<list>
<ref
bean="doTime" />
</list>
</property>
</bean>
</beans>
Java代码:
package com.coalmine.desktop;
import java.text.SimpleDateFormat;
import java.util.Date;
public class QuartzJob {
public
void work() {
SimpleDateFormat
sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Date
date = new Date();
System.out.println(sdf.format(date)
+ " 执行Quartz定时器");
}
}
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:jee="http://www.springframework.org/schema/jee"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-2.0.xsd">
<!--
要调用的工作类 -->
<bean
id="quartzJob"
class="com.coalmine.desktop.QuartzJob"></bean>
<!--
定义调用对象和调用对象的方法 -->
<bean
id="jobtask"
class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">
<!--
调用的类 -->
<property
name="targetObject">
<ref
bean="quartzJob" />
</property>
<!--
调用类中的方法 -->
<property
name="targetMethod">
<value>work</value>
</property>
</bean>
<!--
定义触发时间 -->
<bean
id="doTime"
class="org.springframework.scheduling.quartz.CronTriggerBean">
<property
name="jobDetail">
<ref
bean="jobtask" />
</property>
<!--
cron表达式 -->
<property
name="cronExpression">
<!--
第 10秒
隔 5秒执行一次-->
<value>10/5
* * * * ?</value>
</property>
</bean>
<!--
总管理类 如果将lazy-init='false'那么容器启动就会执行调度程序 -->
<bean
id="startQuertz" lazy-init="false" autowire="no"
class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
<property
name="triggers">
<list>
<ref
bean="doTime" />
</list>
</property>
</bean>
</beans>
相关文章推荐
- [ZZ][Linux App]Ubuntu 9.04快速搭建Apache2(httpd)+PHP5+MySQL完美LAMP服务器
- LAMP(Linux+Apachd+Mysql+Php)搭建网站环境
- 在树莓派上搭建LAMP(Linux Apache Mysql PHP)服务器
- 在树莓派上搭建LAMP(Linux Apache Mysql PHP)服务器
- LAMP(Linux+Apachd+Mysql+Php)搭建网站环境
- WEB服务器linux+apache+mysql+php LAMP源码环境搭建
- CentOS5.3搭建LAMP(Linux, Apache, MySQL, PHP)Web服务器
- 在树莓派上搭建LAMP(Linux Apache Mysql PHP)服务器
- 基于阿里云centOS服务器,LAMP环境搭建(linux+apache+mysql+php)
- LAMP源码环境搭建WEB服务器Linux+Apache+MySQL+PHP
- 如何在服务器上搭建一个lamp(Linux(CentOS7)+Apache+MySQL+PHP)环境
- Ubuntu 9.04快速搭建Apache2(httpd)+PHP5+MySQL完美LAMP服务器
- 项目实训:搭建一台LAMP (Linux+Apache+Mysql+Php)架构的web服务器
- 如何使用mysql(lamp)分离环境搭建dedecms织梦网站及apache服务器常见的403http状态码及其解决方法
- 源码搭建LAMP(Linux+Apache+Mysql+PHP)环境
- linux+nginx+mysql+php高性能服务器搭建
- LNMP(linux+nginx+mysql+php)网站服务器架构
- Linux\CentOS系统下的服务器搭建,下载编译环境,安装vsFtpd、nginx、MySQL、JDK、Tomcat、PHP
- ubuntu13.10 搭建lamp环境(linux+apache+mysql+php)
- 飞飞实验室:CentOS 5.3快速搭建Apache+PHP5+MySQL完美Web服务器(LAMP)