- 浏览: 384129 次
- 性别:
- 来自: 上海
文章分类
- 全部博客 (311)
- 网站开发及性能优化 (1)
- JQUERY滚动加载 (1)
- 网络编辑 (1)
- redis (2)
- memcache (4)
- mongodb (5)
- kafka (7)
- apache (3)
- Nexus (2)
- 操作系统 (21)
- JDK (2)
- MyEclipse (11)
- SVN (4)
- Tomcat (3)
- Solr (4)
- CENTOS (5)
- ubuntu (2)
- 新浪微博api (1)
- elasticsearch (60)
- java (28)
- MAC (6)
- Lucene (4)
- Linux (14)
- mysql (6)
- XenCenter (1)
- ext (3)
- spring (6)
- oracle (4)
- tsp (1)
- JForum (1)
- jms (1)
- CAS (1)
- jquery (6)
- freemarker (2)
- 项目管理 (5)
- CSS (3)
- 事务管理 (1)
- js (3)
- 分词 (1)
- 分词器 (1)
- oauthToken (1)
- hadoop (8)
- spark (1)
- cache (1)
- unicode (1)
- 正则表达式 (1)
- google (1)
- Postfix (4)
- windows (3)
- 搜索引擎 (1)
- notepad (1)
- nginx (1)
- outlook (1)
- Fiddler (2)
- Shadowsocks (0)
- github (1)
- 算法 (4)
- zabbix (1)
- office (2)
- maven (8)
- TeamView (1)
- csv (1)
- mikrotik (1)
- DELL (1)
- USVN (2)
- mybatis (3)
- vue (1)
- python (1)
- zxing (2)
- Intellij idea (0)
- IDEA (2)
- http (2)
- JWT (1)
- CAP (1)
- Nacos (1)
- OpenFeign (1)
- SpringCloud (1)
- feign (1)
- springboot (2)
- skywalking (1)
- 微服务 (2)
- 部署 (1)
- bootstrap (1)
最新评论
-
xam_sunny:
用楼主的第一种方法解决了乱码问题,谢谢分享。
spring 中文乱码 -
lzq570:
...
freemarker中分页
本来很简单的时钟今天配的时候却弄了我2个小时,在这里跟大家分享下错误经验。希望能帮助大家少走弯路。
1,注意jar包,特别是commons-collections.jar这个包的版本要3.x以上的。
2,注意编译jdk和运行jdk的版本问题要不然会报:java.lang.UnsupportedClassVersionError: Bad version number in .class file ...错误
配置一个服务时钟的类源码:
1,ClockService.java:处理时钟业务
Java代码 收藏代码
public class ClockService {
public void doService(){
System.out.println("do Service!");
}
}
2,ClockTime.java:时钟类(QuartzJobBean所属quartz-all-1.6.0.jar版本不一,这里是我用的版本)
Java代码 收藏代码
public class ClockTime extends QuartzJobBean{
protected void executeInternal(JobExecutionContext arg0)
throws JobExecutionException {
System.out.println("============== Time Clock Start =============");
ClockService service = new ClockService();
service.doService();
System.out.println("============== Time Clock End =============");
}
}
3,applicationContext-clock.xml配置时钟
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"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">
<!-- 时钟 -->
<bean id="quartzClock"
class="org.springframework.scheduling.quartz.JobDetailBean">
<property name="jobClass">
<value>com.fairy.spring.clock.ClockTime</value>
</property>
<property name="jobDataAsMap">
<map>
<!-- spring 的依赖注入 -->
<!-- <entry key="service"><ref local="handleOverTimeClockServiceImpl"/></entry> -->
</map>
</property>
</bean>
<bean id="quartzClockTask"
class="org.springframework.scheduling.quartz.SimpleTriggerBean">
<property name="jobDetail">
<ref bean="quartzClock" />
</property>
<property name="startDelay">
<value>6000</value>
<!-- 这里是服务启动后延时多少时间,开始计时任务,单位ms-->
</property>
<property name="repeatInterval">
<value>30000</value>
<!-- 这里是每隔多长时间就进行一次计时任务,单位ms -->
</property>
</bean>
<bean id="cronQuartzClock"
class="org.springframework.scheduling.quartz.CronTriggerBean">
<property name="jobDetail">
<ref bean="quartzClock"></ref>
</property>
<property name="cronExpression">
<!-- <value>0 38 13 * * ?</value> -->
<value>0,5,10,15,20,25,30,35,40,45,50,55 * * * * ?</value>
<!--
<value>0 0,10,20,30,40,50,59 * * * ?</value>
-->
<!--定时在任何月份任何日期(不管星期几)的22点52分0秒 -->
<!-- 一个cron表达式有到少6个(也可能是7个)由空格分隔的时间元素.从左到右,这些元素的定义如下:
1.秒(0-59)
2.分钟(0-59)
3.小时(0-23)
4.月份中的是期(1-31)
5.月份(1-12或SUN-DEC)
6.星期中的日期(1-7或SUN-SAT)
7.年份(1970-2099)
例子:
0 0 10,14,16 * * ? 每天上午10点,下午2点和下午4点
0 0,15,30,45 * 1-10 * ? 每月前10天每隔15分钟
30 0 0 1 1 ? 2012 在2012年1月1日午夜过30秒时
0 0 8-5 ? * MON-FRI 每个工作日的工作时间
- 区间
* 通配符
? 你不想设置那个字段
-->
</property>
</bean>
<bean
class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
<property name="triggers">
<list>
<ref bean="cronQuartzClock"></ref>
</list>
</property>
</bean>
<!-- end 时钟 -->
</beans>
4,web.xml配置spring
Xml代码 收藏代码
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:applicationContext-*.xml</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
http://lochen514.iteye.com/blog/1273240
1,注意jar包,特别是commons-collections.jar这个包的版本要3.x以上的。
2,注意编译jdk和运行jdk的版本问题要不然会报:java.lang.UnsupportedClassVersionError: Bad version number in .class file ...错误
配置一个服务时钟的类源码:
1,ClockService.java:处理时钟业务
Java代码 收藏代码
public class ClockService {
public void doService(){
System.out.println("do Service!");
}
}
2,ClockTime.java:时钟类(QuartzJobBean所属quartz-all-1.6.0.jar版本不一,这里是我用的版本)
Java代码 收藏代码
public class ClockTime extends QuartzJobBean{
protected void executeInternal(JobExecutionContext arg0)
throws JobExecutionException {
System.out.println("============== Time Clock Start =============");
ClockService service = new ClockService();
service.doService();
System.out.println("============== Time Clock End =============");
}
}
3,applicationContext-clock.xml配置时钟
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"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">
<!-- 时钟 -->
<bean id="quartzClock"
class="org.springframework.scheduling.quartz.JobDetailBean">
<property name="jobClass">
<value>com.fairy.spring.clock.ClockTime</value>
</property>
<property name="jobDataAsMap">
<map>
<!-- spring 的依赖注入 -->
<!-- <entry key="service"><ref local="handleOverTimeClockServiceImpl"/></entry> -->
</map>
</property>
</bean>
<bean id="quartzClockTask"
class="org.springframework.scheduling.quartz.SimpleTriggerBean">
<property name="jobDetail">
<ref bean="quartzClock" />
</property>
<property name="startDelay">
<value>6000</value>
<!-- 这里是服务启动后延时多少时间,开始计时任务,单位ms-->
</property>
<property name="repeatInterval">
<value>30000</value>
<!-- 这里是每隔多长时间就进行一次计时任务,单位ms -->
</property>
</bean>
<bean id="cronQuartzClock"
class="org.springframework.scheduling.quartz.CronTriggerBean">
<property name="jobDetail">
<ref bean="quartzClock"></ref>
</property>
<property name="cronExpression">
<!-- <value>0 38 13 * * ?</value> -->
<value>0,5,10,15,20,25,30,35,40,45,50,55 * * * * ?</value>
<!--
<value>0 0,10,20,30,40,50,59 * * * ?</value>
-->
<!--定时在任何月份任何日期(不管星期几)的22点52分0秒 -->
<!-- 一个cron表达式有到少6个(也可能是7个)由空格分隔的时间元素.从左到右,这些元素的定义如下:
1.秒(0-59)
2.分钟(0-59)
3.小时(0-23)
4.月份中的是期(1-31)
5.月份(1-12或SUN-DEC)
6.星期中的日期(1-7或SUN-SAT)
7.年份(1970-2099)
例子:
0 0 10,14,16 * * ? 每天上午10点,下午2点和下午4点
0 0,15,30,45 * 1-10 * ? 每月前10天每隔15分钟
30 0 0 1 1 ? 2012 在2012年1月1日午夜过30秒时
0 0 8-5 ? * MON-FRI 每个工作日的工作时间
- 区间
* 通配符
? 你不想设置那个字段
-->
</property>
</bean>
<bean
class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
<property name="triggers">
<list>
<ref bean="cronQuartzClock"></ref>
</list>
</property>
</bean>
<!-- end 时钟 -->
</beans>
4,web.xml配置spring
Xml代码 收藏代码
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:applicationContext-*.xml</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
http://lochen514.iteye.com/blog/1273240
发表评论
-
基于STS对springboot进行Maven多模块构建
2019-12-10 16:39 477基于STS对springboot进行多模块构建 某人最近想 ... -
Spring实现文件上传(示例代码)
2014-11-21 10:24 893Spring可以继承commons-fileupload插 ... -
spring项目打JAR包读取配置文件
2014-09-01 21:18 2314Spring中使用classpath*加载配置文件,jar ... -
spring 中文乱码
2013-12-03 14:58 3206一、在项目进行中遇到了常见的乱码问题,但用常见的解决手段无法解 ... -
springMVC统一处理异常(转)
2011-10-27 22:06 1796转自:http://hi.baidu.com/99999999 ...
相关推荐
spring配置 spring配置 spring配置 spring配置 spring配置
ssmspring配置ssmspring配置ssmspring配置ssmspring配置ssmspring配置ssmspring配置ssmspring配置ssmspring配置ssmspring配置ssmspring配置ssmspring配置ssmspring配置ssmspring配置ssmspring配置ssmspring配置ssm...
Spring配置 Spring 配置 映射 加注释!!!!Spring配置 Spring 配置 映射 加注释!!!!
spring配置和启动方式 博客地址:https://blog.csdn.net/u010476739/article/details/76696756
spring配置文件实例
Spring配置文件集合Spring配置文件集合Spring配置文件集合Spring配置文件集合Spring配置文件集合Spring配置文件集合Spring配置文件集合
spring数据源配置
spring 动态多数据源配置代码,本项目是maven项目,里面有完成的配资好的spring多数据源代码和配置文件。
spring配置文件spring配置文件spring配置文件spring配置文件spring配置文件spring配置文件spring配置文件spring配置文件spring配置文件spring配置文件spring配置文件spring配置文件spring配置文件spring配置文件...
使用Spring配置文件实现AOP
spring仿写demo代码spring仿写demo代码spring仿写demo代码spring仿写demo代码spring仿写demo代码spring仿写demo代码spring仿写demo代码spring仿写demo代码spring仿写demo代码spring仿写demo代码spring仿写demo代码...
spring配置文件详解,Spring的applicationContext.xml文件代码:
资源我的博客 Spring之依赖配置详解 中 所有使用到的代码和配置实例。
Spring Security 基本使用和配置代码,学习之后自己练习,
spring 配置文件 归类 IOC AOPspring 配置文件 归类 IOC AOP
spring配置最佳实践.zip spring配置最佳实践.zip spring配置最佳实践.zip
Spring的基本配置Spring的基本配置Spring的基本配置Spring的基本配置Spring的基本配置Spring的基本配置Spring的基本配置
spring 配置c3p0 的配置文件 注意是 配置文件
Spring 源代码解析Spring 源代码解析Spring 源代码解析Spring 源代码解析Spring 源代码解析Spring 源代码解析Spring 源代码解析Spring 源代码解析Spring 源代码解析Spring 源代码解析Spring 源代码解析Spring 源代码...