第一篇需要实现一个最简单的需求:某个任务定时执行,多台机子只让其中一台机子执行任务
一、安装 分布式应用程序协调服务 zookeeper,安装步骤在链接里面
Linux(Centos7)下安装 zookeeper docker版 集群
二、在springboot项目中引入 elastic-job 依赖,我这里用的 springboot 2.0.5 版本
整合代码参考官方的springboot demo
https://github.com/elasticjob/elastic-job-example
对应的 elastic-job 版本
<elastic-job.version>2.1.5</elastic-job.version>
<!-- apache elastic-job start --> <dependency> <groupId>com.dangdang</groupId> <artifactId>elastic-job-lite-core</artifactId> <version>${elastic-job.version}</version> </dependency> <dependency> <groupId>com.dangdang</groupId> <artifactId>elastic-job-lite-spring</artifactId> <version>${elastic-job.version}</version> </dependency> <!-- apache elastic-job end -->