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

下载站用什么网站系统广元网站建设专业人员

下载站用什么网站系统,广元网站建设专业人员,在线网站cms识别,揭阳网站制作​ 博客主页: 南来_北往 系列专栏#xff1a;Spring Boot实战 前言 最近一周#xff0c;被借调到其他部门#xff0c;赶一个紧急需求#xff0c;需求内容如下#xff1a; PC网页触发一条设备升级记录#xff08;下图#xff09;#xff0c;后台要定时批量设备更… ​ 博客主页:     南来_北往 系列专栏Spring Boot实战 前言 最近一周被借调到其他部门赶一个紧急需求需求内容如下 PC网页触发一条设备升级记录下图后台要定时批量设备更新。这里定时要用到Quartz批量数据处理要用到SpringBatch二者结合可以完成该需求。 由于之前没有用过SpringBatch于是上网查了下资料发现可参考的不是很多于是只能去慢慢的翻看官方文档。 Spring Batch - Reference Documentation 具体实现 在你的pom.xml文件中添加以下依赖  dependencies!-- Spring Boot --dependencygroupIdorg.springframework.boot/groupIdartifactIdspring-boot-starter/artifactId/dependencydependencygroupIdorg.springframework.boot/groupIdartifactIdspring-boot-starter-batch/artifactId/dependency!-- Quartz --dependencygroupIdorg.quartz-scheduler/groupIdartifactIdquartz/artifactId/dependencydependencygroupIdorg.springframework.boot/groupIdartifactIdspring-boot-starter-quartz/artifactId/dependency /dependencies在application.properties文件中添加以下配置 spring.quartz.job-store-typememory spring.quartz.properties.org.quartz.scheduler.instanceNameMyScheduler spring.quartz.properties.org.quartz.threadPool.threadCount5创建一个实现Job接口的类例如MyBatchJob import org.quartz.Job; import org.quartz.JobExecutionContext; import org.quartz.JobExecutionException; import org.springframework.batch.core.JobParametersBuilder; import org.springframework.batch.core.launch.JobLauncher; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.scheduling.quartz.QuartzJobBean;public class MyBatchJob extends QuartzJobBean {Autowiredprivate JobLauncher jobLauncher;Overrideprotected void executeInternal(JobExecutionContext context) throws JobExecutionException {try {jobLauncher.run(myBatchJob(), new JobParametersBuilder().addString(JobID, String.valueOf(System.currentTimeMillis())).toJobParameters());} catch (Exception e) {throw new JobExecutionException(e);}}private Job myBatchJob() {// 返回你的Spring Batch Job实例} }在你的配置类中例如ApplicationConfig添加一个SchedulerFactoryBean的Bean用于配置定时任务的触发器 import org.quartz.*; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.scheduling.quartz.SchedulerFactoryBean;Configuration public class ApplicationConfig {Beanpublic JobDetail myBatchJobDetail() {return JobBuilder.newJob(MyBatchJob.class).withIdentity(myBatchJob).storeDurably().build();}Beanpublic Trigger myBatchJobTrigger() {SimpleScheduleBuilder scheduleBuilder SimpleScheduleBuilder.simpleSchedule().withIntervalInSeconds(60) // 设置任务执行间隔例如每60秒执行一次.repeatForever(); // 设置任务重复执行return TriggerBuilder.newTrigger().forJob(myBatchJobDetail()).withIdentity(myBatchJobTrigger).withSchedule(scheduleBuilder).build();}Beanpublic SchedulerFactoryBean schedulerFactoryBean() {SchedulerFactoryBean schedulerFactoryBean new SchedulerFactoryBean();schedulerFactoryBean.setJobDetails(myBatchJobDetail());schedulerFactoryBean.setTriggers(myBatchJobTrigger());return schedulerFactoryBean;} }现在你已经成功地整合了Spring Boot、Spring Batch和Quartz实现了定时批量任务。每隔指定的时间间隔例如60秒MyBatchJob将会被执行一次。
http://www.yingshimen.cn/news/88401/

相关文章:

  • 北京公司注册地址要求网站做优化需要哪些后台信息
  • jsp网站搭建网站模版制作
  • 网站wordpress是什么意思wordpress嵌入百度地图可以导航
  • 个人网站推广广告网络推广加盟费多少
  • 网站建设的方案计划无极在线房屋出租信息
  • 个人作品展示网站模板网站建设公司 项目经理 的工作指责
  • 欧美网站建设推广平台怎么找客源
  • 企业网站的建设要注意哪些方面电子商务推广
  • 利用高权重网站做关键词网站下载不了的视频怎么下载
  • 做游戏模板下载网站有哪些内容网站统一建设统一管理
  • asp.net网站本机访问慢专业东莞网站制作公司
  • 石家庄正规网站建设公司中天建设集团有限公司排名
  • 网站建设用什么视频播放器网站开发框架技术
  • 网站一定要备案才能设计app推广工作室
  • 中山网站关键词排名域名购买哪个网站
  • 英语培训学校网站建设多少钱软件开发的主要任务是
  • 弹幕网站是怎么做的网络安全专业就业前景
  • 大连网站建设开发网站制作公司哪儿济南兴田德润有活动吗
  • 网站建设比选文件广州网站建设排名一览表
  • 优秀网站建设价格网站上线后如何换模版
  • html5网站建设基本流程智能网站建设报价
  • wordpress 10万pv汕头seo专家
  • 做网站 怎么备案科室网站建设
  • 做网站的公司 杭州wordpress资讯类主题
  • 网站建设在线菜鸟教程wordpress 简单幻灯片插件
  • 网站管理 官网营销型网站的重要特点
  • 石家庄集团公司网站建设asp 网站 内容静态化
  • 中国建设报社网站hqz行情站
  • 网站建设合同违约wordpress分类目录
  • 做网站有那几种末班设计培训网页班