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

做众筹网站需要什么条件seo策略有哪些

做众筹网站需要什么条件,seo策略有哪些,网站最新程序策划书,小旋风seo官网​ 博客主页: 南来_北往 系列专栏:Spring Boot实战 前言 最近一周,被借调到其他部门,赶一个紧急需求,需求内容如下: PC网页触发一条设备升级记录(下图),后台要定时批量设备更…

 ​

 博客主页:     南来_北往

系列专栏:Spring Boot实战


前言

最近一周,被借调到其他部门,赶一个紧急需求,需求内容如下:

PC网页触发一条设备升级记录(下图),后台要定时批量设备更新。这里定时要用到Quartz,批量数据处理要用到SpringBatch,二者结合,可以完成该需求。

由于之前,没有用过SpringBatch,于是上网查了下资料,发现可参考的不是很多,于是只能去慢慢的翻看官方文档。

Spring Batch - Reference Documentation

具体实现

在你的pom.xml文件中添加以下依赖: 

<dependencies><!-- Spring Boot --><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter</artifactId></dependency><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-batch</artifactId></dependency><!-- Quartz --><dependency><groupId>org.quartz-scheduler</groupId><artifactId>quartz</artifactId></dependency><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-quartz</artifactId></dependency>
</dependencies>

 在application.properties文件中添加以下配置:

spring.quartz.job-store-type=memory
spring.quartz.properties.org.quartz.scheduler.instanceName=MyScheduler
spring.quartz.properties.org.quartz.threadPool.threadCount=5

 创建一个实现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.hkea.cn/news/490493/

相关文章:

  • 用net语言做网站平台好不好企业培训师资格证报考2022
  • 成都定制网站设竞价推广遇到恶意点击怎么办
  • 制作视频网站建设友链交易网
  • 做外贸是不是要有网站腾讯企点app下载安装
  • 网站开发快递文件国外网站怎么推广
  • 网站和搜索引擎站长论坛
  • 做违法网站会怎样外贸独立站怎么建站
  • 云主机建网站教程深圳全网推互联科技有限公司
  • 做网站赚50万谷歌搜索引擎363入口
  • 台州网站设计外包网页制作公司排名
  • 网站建设投标文件范本亚马逊提升关键词排名的方法
  • 学做网站需要多长时间免费推广平台排行
  • wordpress运行php 404360优化大师下载
  • seo排名网站 优帮云线上推广的三种方式
  • 平凉哪有做网站的百度推广登录入口官网网
  • 娄底网站优化自建网站平台有哪些
  • 做网站需要多少兆空间wix网站制作
  • 哪些网站教做生物实验今日新闻联播
  • 铜川市住房和城乡建设局网站信息流广告哪个平台好
  • 太原市建设交易中心网站首页百度手机助手app安卓版官方下载
  • 昆山网站建设网站建设郑州网络推广哪个好
  • 瑜伽网站设计国外推广网站
  • 什么网站做国外批发百度推广自己怎么做
  • 网站管理工具百度推广可以自己开户吗
  • 三水网站制作中山做网站推广公司
  • ysl网站设计论文郑州seo地址
  • 做食品的网站设计要注意片多多可以免费看电视剧吗
  • 网站排名推广自己怎么做长沙seo代理商
  • 手机网站改版公司加盟关键词优化排名查询
  • html5 图片网站建设企业网站多少钱