1、stock_job工程集成xxljob
我们按照xxl-job-executor-sample-springboot工程整合流程,将xxljob整合到stock_job工程下,流程如下:
1)stock_job工程引入核心依赖
<!--引入xxljob核心依赖-->
<dependency>
<groupId>com.xuxueli</groupId>
<artifactId>xxl-job-core</artifactId>
</dependency>
2)在application-stock.yml就行添加xxljob配置
# XXJOB参数配置
xxl:
job:
accessToken:
admin:
addresses: http://192.168.200.1:8093/xxl-job-admin
executor:
appname: heima-stock-job-executor
address:
ip:
port: 6767
logpath: .\logs
logretentiondays: 30
注意:.gitignore文件中应忽略logs目录
激活该配置:
spring:
profiles:
active: stock
3)定义xxljob 核心配合bean
我们直接将xxl-job-executor-sample-springboot工程下的XxlJobConfig类复制过来即可:
package com.itheima.stock.job.xxljobconfig;
import com.xxl.job.core.executor.impl.XxlJobSpringExecutor;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.con