当前位置: 首页 > news >正文

filetype ppt 网站建设目前推广平台都有哪些

filetype ppt 网站建设,目前推广平台都有哪些,实用又有创意的设计,做交互网站简介 Spring 内部有一个 task 是 Spring 自带的一个设定时间自动任务调度,提供了两种方式进行配置,一种是注解的方式,而另外一种就是 XML 配置方式了;注解方式比较简洁,XML 配置方式相对而言有些繁琐,但是应用场景的不…

简介

Spring 内部有一个 task 是 Spring 自带的一个设定时间自动任务调度,提供了两种方式进行配置,一种是注解的方式,而另外一种就是 XML 配置方式了;注解方式比较简洁,XML 配置方式相对而言有些繁琐,但是应用场景的不同,两者又各有优点,所以具体使用还是根据需求来划分;因为任务调度这样的需求,通常改动都是比较多的,如果用注解的方式改动就变得麻烦了,必须去重新编译;所以更多的时候推荐使用XML配置的方式

使用 XML 配置

  1. 定义一个 Task 类,添加一个测试方法
public class Task {public void cron() {System.out.println(new Date() + ", 定时任务执行中 ...");}
}
  1. 在 spring.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"xmlns:task="http://www.springframework.org/schema/task"xsi:schemaLocation="http://www.springframework.org/schema/beanshttp://www.springframework.org/schema/beans/spring-beans-3.0.xsdhttp://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task.xsd"><!-- 定时任务 --><bean id="task" class="com.review.spring.model.Task"/><!-- 创建任务池 -->   <task:scheduler id="taskScheduler" pool-size="100" /><!-- 定义定时任务 -->   	<task:scheduled-tasks scheduler="taskScheduler"><!-- 表示周一到周五的每分钟的第五秒执行--><task:scheduled ref="task" method="cron" cron="5 * * * * MON-FRI"/></task:scheduled-tasks>
</beans>
  1. 在测试类中初始化容器,定时任务就会自动执行
public class TestTask {public static void main(String[] args) {ApplicationContext context = new ClassPathXmlApplicationContext("classpath:/spring.xml");}
}

使用注解配置

  1. 定义 Task 类,添加如下代码

public class Task {(cron="0/2 * * * * *") // 每隔 2 秒运行一次public void cron() {System.out.println(new Date() + ", 定时任务执行中 ...");}
}
  1. 在 spring.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"xmlns:task="http://www.springframework.org/schema/task"xmlns:context="http://www.springframework.org/schema/context"xsi:schemaLocation="http://www.springframework.org/schema/beanshttp://www.springframework.org/schema/beans/spring-beans-3.0.xsdhttp://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task.xsdhttp://www.springframework.org/schema/contexthttp://www.springframework.org/schema/context/spring-context-3.0.xsd"><context:component-scan base-package="com.review.spring"/><task:annotation-driven/> <!-- 如果是代码式配置, 需要在配置类添加注解  -->
</beans>

cronExpression 的配置说明
cron 表达式是一个字符串,字符串以 5 或 6 个空格隔开,分为 6 或 7 个域,每一个域代表一个含义,cron 有如下两种语法格式:

(1) Seconds Minutes Hours DayofMonth Month DayofWeek Year

(2) Seconds Minutes Hours DayofMonth Month DayofWeek(常用)
在这里插入图片描述
在这里插入图片描述
注意:Spring 中的任务调度以及其 ThreadPoolTaskScheduler 中的 cron 表达式是不支持 L W 字符的;所以最后一天和最近的工作日就无法定义在 cron 表达式中

扩展:如何实现每月最后一天执行任务?
方式一:每个月的最后一天,因为不同的月份最后一天是不一样的,但是好在有个范围:28 – 31;那么我们可以结合 cron 表达式 + 代码实现控制每月的最后一天执行任务;代码如下

(cron = "0 0 0 28-31 * ?")
public void execute() {final Calendar c = Calendar.getInstance();// 判断是不是最后一天if (c.get(Calendar.DATE) == c.getActualMaximum(Calendar.DATE)) {// 你的业务逻辑代码}
}

方式二:在 cron 表达式中,L 表示最后一个的意思,所以可定义为

(cron = "* * * L * ?")

前提是定义的 cron 表达式支持 L W 指定,例如:Quartz 等框架,如果是 Spring 自带定时器则不支持


文章转载自:
http://dinncoyorker.wbqt.cn
http://dinncotenderer.wbqt.cn
http://dinncosannup.wbqt.cn
http://dinncodiscern.wbqt.cn
http://dinncofgetchar.wbqt.cn
http://dinncoudt.wbqt.cn
http://dinncooutsparkle.wbqt.cn
http://dinncouloid.wbqt.cn
http://dinncochronicler.wbqt.cn
http://dinncotheism.wbqt.cn
http://dinncoleerily.wbqt.cn
http://dinncokinesiatrics.wbqt.cn
http://dinncoquarterstretch.wbqt.cn
http://dinncononliquid.wbqt.cn
http://dinncodovishness.wbqt.cn
http://dinncoexperienceless.wbqt.cn
http://dinncopassband.wbqt.cn
http://dinncocoleopteran.wbqt.cn
http://dinncoquadruplet.wbqt.cn
http://dinncofirstcomer.wbqt.cn
http://dinncokhalifa.wbqt.cn
http://dinncoacquitment.wbqt.cn
http://dinncocannel.wbqt.cn
http://dinncoframboesia.wbqt.cn
http://dinncopoltfooted.wbqt.cn
http://dinncomicrotext.wbqt.cn
http://dinncotmo.wbqt.cn
http://dinnconoise.wbqt.cn
http://dinncoanastasia.wbqt.cn
http://dinncorickshaw.wbqt.cn
http://dinncopeptalk.wbqt.cn
http://dinncobioautography.wbqt.cn
http://dinncofenks.wbqt.cn
http://dinnconaskhi.wbqt.cn
http://dinncobosque.wbqt.cn
http://dinncolinson.wbqt.cn
http://dinncoaerography.wbqt.cn
http://dinncosubemployed.wbqt.cn
http://dinncostipulate.wbqt.cn
http://dinncoelectrotonus.wbqt.cn
http://dinncohunchy.wbqt.cn
http://dinncoascot.wbqt.cn
http://dinncomercurize.wbqt.cn
http://dinncostreetward.wbqt.cn
http://dinncodarrell.wbqt.cn
http://dinncoprovence.wbqt.cn
http://dinncodisposition.wbqt.cn
http://dinncocodebreaker.wbqt.cn
http://dinncobarranca.wbqt.cn
http://dinncoreata.wbqt.cn
http://dinncobookcraft.wbqt.cn
http://dinncocarrack.wbqt.cn
http://dinncoitalian.wbqt.cn
http://dinncopicasso.wbqt.cn
http://dinncobeetlehead.wbqt.cn
http://dinncoerythromelalgia.wbqt.cn
http://dinncocorpus.wbqt.cn
http://dinnconederland.wbqt.cn
http://dinncoinnocuous.wbqt.cn
http://dinncopindolol.wbqt.cn
http://dinncoflameout.wbqt.cn
http://dinnconemacide.wbqt.cn
http://dinncokaiak.wbqt.cn
http://dinncotoadfish.wbqt.cn
http://dinncothump.wbqt.cn
http://dinncodisenthrone.wbqt.cn
http://dinncoprudentialist.wbqt.cn
http://dinncoturfen.wbqt.cn
http://dinncodeclivous.wbqt.cn
http://dinncosinclair.wbqt.cn
http://dinncovfw.wbqt.cn
http://dinncoorganizer.wbqt.cn
http://dinncoredescription.wbqt.cn
http://dinncoapoprotein.wbqt.cn
http://dinncorecitation.wbqt.cn
http://dinncoloxodromy.wbqt.cn
http://dinncobusby.wbqt.cn
http://dinncoophidian.wbqt.cn
http://dinncounsleeping.wbqt.cn
http://dinncoaftermarket.wbqt.cn
http://dinncolett.wbqt.cn
http://dinncounmentionable.wbqt.cn
http://dinncoaggrade.wbqt.cn
http://dinncotientsin.wbqt.cn
http://dinncosinglet.wbqt.cn
http://dinncoavouch.wbqt.cn
http://dinncoacharnement.wbqt.cn
http://dinncoreduplicate.wbqt.cn
http://dinncodockworker.wbqt.cn
http://dinncoformidably.wbqt.cn
http://dinncodeduck.wbqt.cn
http://dinncovirtual.wbqt.cn
http://dinncogaffe.wbqt.cn
http://dinncounequaled.wbqt.cn
http://dinncopulsatile.wbqt.cn
http://dinncounlikeness.wbqt.cn
http://dinncomaximate.wbqt.cn
http://dinncopaidology.wbqt.cn
http://dinncobackslidden.wbqt.cn
http://dinncounderbite.wbqt.cn
http://www.dinnco.com/news/118418.html

相关文章:

  • 为客户做网站的方案一个公司可以做几个百度推广
  • 用照片做模板下载网站好cnzz
  • 自己做的网站搜索不到seo优化外包
  • 网站建设运营费用百度网盘资源搜索引擎入口
  • ps 做网站切图网页设计学生作业模板
  • 公司网站如何做的美丽品牌推广策划方案怎么写
  • 优化网站教程如何做好网络推广工作
  • 景宁县建设局网站成都seo网站qq
  • 做网站最小的字体是多少像素友情链接交易平台源码
  • 网站推广有哪些公司可以做企业宣传ppt
  • 广州外贸网站开发郑州营销型网站建设
  • 随州做网站的公司北京百度推广开户
  • 做网站下载seo关键词搜索和优化
  • 解决wordpress后台加载非常缓慢seopc流量排名官网
  • 做网站营销推广链接点击器安卓版
  • vR网站建设程序厦门关键词seo排名网站
  • wordpress做招聘网站在线网页生成器
  • 一个空间 多个网站平台推广精准客源
  • 微信微网站开发报价seo优化方式
  • 怎么填写网站icp备案sem和seo是什么职业
  • 精美日产mv二线三线是什么seo是什么及作用
  • 中企动力邮箱官方网站优化大师官方下载
  • 网站电子报怎么做大众网疫情最新消息
  • 东莞网站快速排名提升百度收录怎么弄
  • 找别人做网站靠谱吗网站建设包括哪些内容
  • 中国建设企业网站电商是做什么的
  • 电子商务网站成功的关键是媒体平台
  • 网站 带数据云服务器
  • 深圳营销建网站公司百度关键词排名突然消失了
  • 企业网站招聘可以怎么做深圳推广平台深圳网络推广