springboot 使用 分布式调度平台 xxl-job记录

文档官网地址:http://www.xuxueli.com/xxl-job/#/

github地址: https://github.com/xuxueli/xxl-job/

下载源码包:

将下载的bao解压: 需要如下四个红框的包。  springboot环境

 

 将 doc下 db文件在mysql中执行: 

 

 修改xxl-job-admin   任务调度平台的数据库地址与帐号密码

 

 

设置任务调度平台的登录帐号密码:xxl-job-admin

 

启动任务调度平台:xxl-job-admin

 

访问启动的任务调度平台 xxl-job-admin , 访问地址在application.properties中配置的

地址:http://localhost:8080/xxl-job-admin/jobinfo

 

 

 

创建一个springboot项目: pom.xml中引入如下依赖, 重点在于:xxl-job-core  这个jar包。  maven repository中央仓库没有最新的jar包, 需要在eclipse或者ide中引入。

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
	<modelVersion>4.0.0</modelVersion>
	<groupId>com.tang</groupId>
	<artifactId>xxl-job</artifactId>
	<version>1.0-SNAPSHOT</version>

	<parent>
		<groupId>org.springframework.boot</groupId>
		<artifactId>spring-boot-starter-parent</artifactId>
		<version>2.1.0.RELEASE</version>
	</parent>


	<properties>
		<java.version>1.8</java.version>
		<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
	</properties>

	<dependencies>
		<!-- starter-web:spring-webmvc + autoconfigure + logback + yaml + tomcat -->
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-web</artifactId>
		</dependency>
		<!-- starter-test:junit + spring-test + mockito -->
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-test</artifactId>
			<scope>test</scope>
		</dependency>

		<!-- freemarker-starter -->
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-freemarker</artifactId>
		</dependency>

		<!-- mail-starter -->
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-mail</artifactId>
		</dependency>

		<!-- mybatis-starter:mybatis + mybatis-spring + tomcat-jdbc(default) -->
		
		<!-- xxl-job-core -->
		<dependency>
			<groupId>com.xuxueli</groupId>
			<artifactId>xxl-job-core</artifactId>
			<version>2.1.0</version>
		</dependency>

	</dependencies>

	<build>
		<plugins>
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-compiler-plugin</artifactId>
				<version>3.8.0</version>
				<configuration>
					<source>1.8</source>
					<target>1.8</target>
				</configuration>
			</plugin>
			<plugin>
				<groupId>org.springframework.boot</groupId>
				<artifactId>spring-boot-maven-plugin</artifactId>
				<configuration>
					<maimClass>com.tang.controller.Main</maimClass>
				</configuration>
				<executions>
					<execution>
						<goals>
							<goal>repackage</goal>
						</goals>
					</execution>
				</executions>
			</plugin>
		</plugins>
	</build>

</project>

 

复制xxl-job-executor-sample-springboot 中的几个配置文件到新建的项目中:

 

配置application.properties  中执行器的IP地址:

 

新建一个 handler文件: 继承 IJobHandler

 

 启动新建的项目:

 

 

任务调度中心配置:xxl-job-admin

创建一个执行器

 

任务管理器设置:

 

填写对应的策略;     JobHandler 为 创建的MyHandler的名称。

 

 

 

 

运行任务:

 

查看结果:

 

 

 路由策略: 可自己根据需要选择

 

 

 

首页图表可查看任务详情;

 

 

任务执行日志查看;

 

其他使用则查看文档: http://www.xuxueli.com/xxl-job/#/ 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值