当前位置:

首页 > 编程开发 > SpringBoot Schedule调度任务的动态管理方法是什么

SpringBoot Schedule调度任务的动态管理方法是什么

前言定时任务动态管理分为两种方式:方式一:Web前台配置Trigger触发器(关联Cron)、ThreadPoolTaskScheduler类创建Scheduler方式下进行Schedule调度任务的动态管理方式二:基于已创建的Schedule调度任务的动态管理,即以组件类@Scheduled注解声明Schedule调度,在启动程序前一次性初始化,如:@ComponentpublicclassTestTask{privateDateTimeFormatterdf=DateTimeFormatter.ofP

本文目录

    前言

    定时任务动态管理分为两种方式:

    方式一:Web前台配置Trigger触发器(关联Cron)、ThreadPoolTaskScheduler类创建Scheduler方式下进行Schedule调度任务的动态管理

    方式二:基于已创建的Schedule调度任务的动态管理,即以组件类 @Scheduled注解声明Schedule调度,在启动程序前一次性初始化,如:

    @Component
    public class TestTask {
        private DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
        @Scheduled(cron = "0/2 * * * * ?")
        public void robReceiveExpireTask() {
            System.out.println(df.format(LocalDateTime.now()) + "测试测试");
        }
    }

    缺陷:目前无法在运行期间增加Schedule以及stop、Start、Reset等管理。

    一、架构流程图

    SpringBoot Schedule调度任务的动态管理方法是什么

    二、代码实现流程

    架构为SpringBoot + Spring + mybatis-plus

    1.引入库

    pom.xml

    
    
        
            merak-hyper-automation-boot
            com.merak.automation
            1.0.0
        
        4.0.0
        automation-quartz
        jar
        
            
                aliyun
                aliyun Repository
                http://maven.aliyun.com/nexus/content/groups/public
                
                    false
                
            
        
        
            
            
                org.springframework
                spring-context-support
            
            
            
                org.springframework
                spring-web
            
            
            
                mysql
                mysql-connector-java
            
            
            
                com.alibaba
                druid-spring-boot-starter
            
            
                org.apache.commons
                commons-lang3
            
            
                jakarta.validation
                jakarta.validation-api
            
            
                com.alibaba
                fastjson
            
            
                commons-io
                commons-io
            
            
                com.fasterxml.jackson.core
                jackson-annotations
            
            
            
                org.springframework.boot
                spring-boot-starter-quartz
                2.2.5.RELEASE
            
        
        
            
                
                
                    org.springframework.boot
                    spring-boot-maven-plugin
                
            
        
    

    resources目录下文件/application.yml:

    spring:

    profiles:

    active: dev

    resources目录下文件/application-dev.yml:

    server:
      port: 12105
      servlet:
        context-path: /automation-quartz

    management:
      endpoints:
        web:
          exposure:
            include: '*'

    # Spring配置
    spring:
      resources:
        static-locations: classpath:/static/,classpath:/templates/
      mvc:
        throw-exception-if-no-handler-found: true
        static-path-pattern: /**
      application:
        name: automation-workflow
      main:
        allow-bean-definition-overriding: true
      # 文件上传
      servlet:
        multipart:
          # 单个文件大小
          max-file-size: 2000MB
          # 设置总上传的文件大小
          max-request-size: 4000MB
      #json 时间戳统一转换
      jackson:
        date-format: yyyy-MM-dd HH:mm:ss
        time-zone: GMT+8
      aop:
        proxy-target-class: true
      autoconfigure:
        exclude: com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceAutoConfigure
      datasource:
        dynamic:
          druid:
            # 全局druid参数,绝大部分值和默认保持一致。(现已支持的参数如下,不清楚含义不要乱设置)
            # 连接池的配置信息
            # 初始化大小,最小,最大
            initial-size: 1
            min-idle: 1
            maxActive: 20
            # 配置获取连接等待超时的时间
            maxWait: 60000
            # 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒
            timeBetweenEvictionRunsMillis: 60000
            # 配置一个连接在池中最小生存的时间,单位是毫秒
            minEvictableIdleTimeMillis: 300000
            validationQuery: SELECT 1
            testWhileIdle: true
            testOnBorrow: false
            testOnReturn: false
            # 打开PSCache,并且指定每个连接上PSCache的大小
            poolPreparedStatements: true
            maxPoolPreparedStatementPerConnectionSize: 20
            # 配置监控统计拦截的filters,去掉后监控界面sql无法统计,'wall'用于防火墙
            filters: stat,wall,slf4j
            # 通过connectProperties属性来打开mergeSql功能;慢SQL记录
            connectionProperties: druid.stat.mergeSql\=true;druid.stat.slowSqlMillis\=5000
          datasource:
            master:
              url: jdbc:mysql://127.0.0.1:3308/merak_dev?characterEncoding=UTF-8&useUnicode=true&useSSL=false
              username: root
              password: root
              driver-class-name: com.mysql.jdbc.Driver

    #mybatis plus 设置
    mybatis-plus:
      mapper-locations: classpath*:com/merak/hyper/automation/persist/**/xml/*Mapper.xml
      global-config:
        # 关闭MP3.0自带的banner
        banner: false
        db-config:
          id-type: ID_WORKER_STR
          # 默认数据库表下划线命名
          table-underline: true
      configuration:
        log-impl: org.apache.ibatis.logging.slf4j.Slf4jImpl
    #    log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
    logging:
      level:
        com.merar.hyper: debug
        com.merak.hyper.automation.persist.**.mapper: debug
        org.springframework: warn

    2.代码流程

    启动MerakQuartzApplication类

    package com.merak.hyper.automation;
    import org.mybatis.spring.annotation.MapperScan;
    import org.slf4j.Logger;
    import org.slf4j.LoggerFactory;
    import org.springframework.boot.SpringApplication;
    import org.springframework.boot.autoconfigure.SpringBootApplication;
    import org.springframework.boot.autoconfigure.security.servlet.SecurityAutoConfiguration;
    import org.springframework.context.annotation.Bean;
    import org.springframework.scheduling.annotation.EnableAsync;
    import org.springframework.scheduling.annotation.EnableScheduling;
    import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
    import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler;
    import java.util.concurrent.Executor;
    import java.util.concurrent.ThreadPoolExecutor;
    /**
     * @author chenjun
     * @version 1.0
     * @ClassName: MerakQuartzApplication
     * @description: 工单任务调度
     * @date 2022/9/22 10:30
     */
    @EnableScheduling
    @EnableAsync
    @MapperScan(basePackages = {"com.merak.hyper.automation.persist.**.mapper"})
    @SpringBootApplication(scanBasePackages = {"com.merak.hyper.automation.**"}, exclude = {SecurityAutoConfiguration.class})
    public class MerakQuartzApplication {
        public static final Logger log = LoggerFactory.getLogger(MerakQuartzApplication.class);
        public static void main(String[] args) {
            SpringApplication.run(MerakQuartzApplication.class, args);
        }
        private int taskSchedulerCorePoolSize = 15;
        private int awaitTerminationSeconds = 60;
        private String threadNamePrefix = "taskExecutor-";
        /**
         * @description: 实例化ThreadPoolTaskScheduler对象,用于创建ScheduledFuture scheduledFuture
         */
        @Bean
        public ThreadPoolTaskScheduler threadPoolTaskScheduler() {
            ThreadPoolTaskScheduler taskScheduler = new ThreadPoolTaskScheduler();
            taskScheduler.setPoolSize(taskSchedulerCorePoolSize);
            taskScheduler.setThreadNamePrefix(threadNamePrefix);
            taskScheduler.setWaitForTasksToCompleteOnShutdown(false);
            taskScheduler.setAwaitTerminationSeconds(awaitTerminationSeconds);
            /**需要实例化线程*/
            taskScheduler.initialize();
    //        isinitialized = true;
            log.info("初始化ThreadPoolTaskScheduler ThreadNamePrefix=" + threadNamePrefix + ",PoolSize=" + taskSchedulerCorePoolSize
                    + ",awaitTerminationSeconds=" + awaitTerminationSeconds);
            return taskScheduler;
        }
        /**
         * @description: 实例化ThreadPoolTaskExecutor对象,管理asyncTask启动的线程,应用类为 ScheduledHelper 
         */
        @Bean("asyncTaskExecutor")
        public Executor taskExecutor() {
            ThreadPoolTaskExecutor taskExecutor = new ThreadPoolTaskExecutor();
            taskExecutor.setCorePoolSize(5);
            taskExecutor.setMaxPoolSize(50);
            taskExecutor.setQueueCapacity(200);
            taskExecutor.setKeepAliveSeconds(60);
            taskExecutor.setThreadNamePrefix("asyncTaskExecutor-");
            taskExecutor.setWaitForTasksToCompleteOnShutdown(true);
            taskExecutor.setAwaitTerminationSeconds(60);
            //修改拒绝策略为使用当前线程执行
            taskExecutor.setRejectedExecutionHandler(new ThreadPoolExecutor.CallerRunsPolicy());
            //初始化线程池
            taskExecutor.initialize();
            return taskExecutor;
        }
    }

    一、启动时项目启动时,加载任务关联的触发器,并全量执行流程。

    initLineRunner类:

    package com.merak.hyper.automation.Scheduling;
    import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
    import com.merak.hyper.automation.persist.entity.AutoTriggerInfo;
    import com.merak.hyper.automation.persist.entity.BusWorkflow;
    import com.merak.hyper.automation.persist.service.IAutoTriggerInfoService;
    import com.merak.hyper.automation.persist.service.IBusWorkflowService;
    import com.merak.hyper.automation.util.CommonUtil;
    import com.merak.hyper.automation.util.ScheduleUtil;
    import org.slf4j.Logger;
    import org.slf4j.LoggerFactory;
    import org.springframework.beans.factory.annotation.Autowired;
    import org.springframework.boot.CommandLineRunner;
    import org.springframework.core.annotation.Order;
    import org.springframework.stereotype.Component;
    import java.time.LocalDateTime;
    import java.time.format.DateTimeFormatter;
    import java.util.Iterator;
    import java.util.List;
    import java.util.Map;
    /**
     * 项目启动时,加载数字员工关联的触发器,并全量执行
     * @Date: 2020/12/25:16:00
     **/
    @Component
    @Order(1)
    public class initLineRunner implements CommandLineRunner {
        public static final Logger log = LoggerFactory.getLogger(initLineRunner.class);
        private DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
        @Autowired
        private TaskService taskService;
        @Autowired
        private IAutoTriggerInfoService triggerInfoService;
        @Autowired
        private IBusWorkflowService workflowService;
        @Override
        public void run(String... args) {
            log.info("项目启动:加载数字员工关联的触发器信息并全量执行," + df.format(LocalDateTime.now()));
            QueryWrapper wrapper = new QueryWrapper<>();
            wrapper.eq("wf_type", "3");//3:云托管
            wrapper.eq("wf_state", "1");
            List busWorkflows = workflowService.list(wrapper);
            List triggerInfos =  triggerInfoService.list();
            if( 0 == busWorkflows.size() || 0 == triggerInfos.size() ){
                log.info("数字员工关联的触发器信息不正确,员工记录数:"+busWorkflows.size()+",触发器记录数:"+triggerInfos.size());
            }
            else{
                //数字员工关联的触发器信息
                Map loadWfidAndTriggerInfo = CommonUtil.loadWfidAndTriggerInfo(busWorkflows,triggerInfos);
                Iterator> entries = loadWfidAndTriggerInfo.entrySet().iterator();
                while (entries.hasNext()) {
                    Map.Entry entry = entries.next();
                    String wfId = entry.getKey();
                    BusWorkflow workflow = busWorkflows.stream().filter( t -> wfId.equals(t.getWfId()) ).findAny().orElse(null);
                    if( null != workflow ){
                        ScheduleUtil.start(new ScheduleTask(wfId,String.valueOf(workflow.getWfCreateuserId()),taskService), entry.getValue());
                    }
                }
                log.info("数字员工关联的触发器信息全量执行完成,数字员工定时个数:"+loadWfidAndTriggerInfo.size()+","+df.format(LocalDateTime.now()));
            }
        }
    }
    核心代码:
    ```java
      ScheduleUtil.start(new ScheduleTask(wfId,String.valueOf(workflow.getWfCreateuserId()),taskService), entry.getValue());

    Scheduler管理工具类:启动、取消、修改等管理

    package com.merak.hyper.automation.util;
    import com.merak.hyper.automation.Scheduling.ScheduleTask;
    import com.merak.hyper.automation.persist.entity.AutoTriggerInfo;
    import org.slf4j.Logger;
    import org.slf4j.LoggerFactory;
    import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler;
    import org.springframework.scheduling.support.CronTrigger;
    import java.util.HashMap;
    import java.util.Map;
    import java.util.concurrent.ScheduledFuture;
    /**
     * @version 1.0
     * @ClassName: ScheduleUtil
     * @description: Scheduler管理工具类:启动、取消、修改等管理
     */
    public class ScheduleUtil {
        public static final Logger log = LoggerFactory.getLogger(ScheduleUtil.class);
        private static ThreadPoolTaskScheduler threadPoolTaskScheduler = SpringContextUtils.getBean(ThreadPoolTaskScheduler.class);
        //存储[数字员工wfI,dScheduledFuture]集合
        private static Map> scheduledFutureMap = new HashMap<>();
        /**
         * 启动
         *
         * @param scheduleTask 定时任务
         * @param triggerInfo
         */
        public static boolean start(ScheduleTask scheduleTask, AutoTriggerInfo triggerInfo) {
            String wfId = scheduleTask.getId();
            log.info("启动数字员工"+wfId+"定时任务线程" + scheduleTask.getId());
            ScheduledFuture scheduledFuture = threadPoolTaskScheduler.schedule(scheduleTask, new CronTrigger(triggerInfo.getLogicConfig()));
            scheduledFutureMap.put(wfId, scheduledFuture);
            return true;
        }
        /**
         * 取消
         *
         * @param scheduleTask 定时任务
         */
        public static boolean cancel(ScheduleTask scheduleTask) {
            log.info("关闭定时任务线程 taskId " + scheduleTask.getId());
            ScheduledFuture scheduledFuture = scheduledFutureMap.get(scheduleTask.getId());
            if (scheduledFuture != null && !scheduledFuture.isCancelled()) {
                scheduledFuture.cancel(false);
            }
            scheduledFutureMap.remove(scheduleTask.getId());
            return true;
        }
        /**
         * 修改
         *
         * @param scheduleTask 定时任务
         * @param triggerInfo
         */
        public static boolean reset(ScheduleTask scheduleTask, AutoTriggerInfo triggerInfo) {
            //先取消定时任务
            cancel(scheduleTask);
            //然后启动新的定时任务
            start(scheduleTask, triggerInfo);
            return true;
        }
    }

    ScheduleTask类:ScheduleTask任务类

    package com.merak.hyper.automation.Scheduling;
    import org.slf4j.Logger;
    import org.slf4j.LoggerFactory;
    /**
     * @version 1.0
     * @ClassName: ScheduleTask
     * @description: ScheduleTask,关联任务id、用户id和具体执行的TaskService类,实现Runnable类
     */
    public class ScheduleTask implements Runnable {
        private static final int TIMEOUT = 30000;
        private String id;
        private String userId;
        private TaskService service;
        public static final Logger log = LoggerFactory.getLogger(ScheduleTask.class);
        public String getId() {
            return id;
        }
        /**
         * @param id      任务ID
         * @param service 业务类
         */
        public ScheduleTask(String id, String userId, TaskService service) {
            this.id = id;
            this.userId = userId;
            this.service = service;
        }
        @Override
        public void run() {
            log.info("ScheduleTask-执行数字员工消息的发送,id:"+ this.id + ",用户id:"+userId);
            service.work(this.id,this.userId);
        }
    }
    /**
     * @version 1.0
     * @ClassName: TaskService
     * @description: TaskService
     */
    public interface TaskService {
        /**
         * 业务处理方法
         * @param keyword 关键参数
         * @param userId
         */
        void work(String keyword,String userId);
    }
    /**
     * @description: TaskService实现类,具体执行定时调度的业务
     */
    @Service
    public class TaskServiceImpl implements TaskService {
        public static final Logger log = LoggerFactory.getLogger(TaskServiceImpl.class);
        @Autowired
        private IAutoDeviceInfoService deviceInfoService;
        @Override
        public void work(String wfId,String userId) {
            try {
                log.info("定时任务:根据数字员工wfId"+ wfId +",用户id:"+userId+",发送消息...");
                //sendRobotMsg(wfId,userId);
                Thread.sleep(200);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }

    二、通过WEB配置的变更,动态管理定时任务

    ScheduledController类:scheduled Web业务层:启动、取消、修改等管理schedule

    调度任务信息变更(如1:Trigger Cron变更 2:任务停止 3:任务新增加等)

    package com.merak.hyper.automation.controller;
    import com.merak.hyper.automation.common.core.domain.AjaxResult;
    import com.merak.hyper.automation.common.core.vo.ScheduledApiVo;
    import com.merak.hyper.automation.persist.entity.AutoTriggerInfo;
    import com.merak.hyper.automation.persist.service.IAutoTriggerInfoService;
    import com.merak.hyper.automation.util.ScheduledHelper;
    import org.slf4j.Logger;
    import org.slf4j.LoggerFactory;
    import org.springframework.beans.factory.annotation.Autowired;
    import org.springframework.web.bind.annotation.*;
    /**
     * @version 1.0
     * @ClassName: ScheduledController
     * @description: scheduled Web业务层:启动、取消、修改等管理schedule
     */
    @RestController
    @RequestMapping("/api/scheduled")
    public class ScheduledController {
        public static final Logger log = LoggerFactory.getLogger(ScheduledController.class);
        @Autowired
        private IAutoTriggerInfoService triggerInfoService;
        @Autowired
        private ScheduledHelper scheduledHelper;
        @PostMapping("/add")
        public AjaxResult addScheduleds(@RequestBody ScheduledApiVo scheduledApiVo){
            AutoTriggerInfo autoTriggerInfo = triggerInfoService.getById(scheduledApiVo.getTriggerId());
            scheduledHelper.addScheduleds(scheduledApiVo,autoTriggerInfo);
            return AjaxResult.success();
        }
        @PostMapping("/reset")
        public AjaxResult resetScheduleds(@RequestBody ScheduledApiVo scheduledApiVo){
            AutoTriggerInfo autoTriggerInfo = triggerInfoService.getById(scheduledApiVo.getTriggerId());
            scheduledHelper.resetScheduleds(scheduledApiVo,autoTriggerInfo);
            return AjaxResult.success();
        }
        @PostMapping("/stop")
        public AjaxResult stopScheduleds(@RequestBody ScheduledApiVo scheduledApiVo){
            AutoTriggerInfo autoTriggerInfo = triggerInfoService.getById(scheduledApiVo.getTriggerId());
            scheduledHelper.stopScheduleds(scheduledApiVo);
            return AjaxResult.success();
        }
    }
    ScheduledHelper类:对外提供ScheduledHelper管理:创建、变更、停止
    ```java
    package com.merak.hyper.automation.util;
    import com.merak.hyper.automation.Scheduling.ScheduleTask;
    import com.merak.hyper.automation.Scheduling.TaskService;
    import com.merak.hyper.automation.common.core.vo.ScheduledApiVo;
    import com.merak.hyper.automation.persist.entity.AutoTriggerInfo;
    import org.slf4j.Logger;
    import org.slf4j.LoggerFactory;
    import org.springframework.scheduling.annotation.Async;
    import org.springframework.stereotype.Component;
    /**
     * @version 1.0
     * @ClassName: ScheduledHelper
     * @description:对外提供ScheduledHelper管理:创建、变更、停止
     */
    @Component
    public class ScheduledHelper {
        public static final Logger log = LoggerFactory.getLogger(ScheduledHelper.class);
        /**
         * @description: 对外(Web)提供异步的Scheduleds增加操作
         */
        @Async("asyncTaskExecutor")
        public void addScheduleds(ScheduledApiVo scheduledApiVo, AutoTriggerInfo triggerInfo) {
            //addSchedule任务
            log.warn("创建原数字员工["+scheduledApiVo.getWfId()+"],同步启动Schedule任务");
            TaskService taskService = SpringContextUtils.getBean(TaskService.class);
            ScheduleUtil.start(new ScheduleTask(scheduledApiVo.getWfId(), scheduledApiVo.getUserId(), taskService), triggerInfo);
        }
        @Async("asyncTaskExecutor")
        public void resetScheduleds(ScheduledApiVo scheduledApiVo,AutoTriggerInfo triggerInfo) {
            //cron值改变,变更Schedule任务
            log.warn("数字员工["+scheduledApiVo.getWfId()+"]关联的触发器信息cron值改变,变更Schedule任务");
            TaskService taskService = SpringContextUtils.getBean(TaskService.class);
            ScheduleUtil.reset(new ScheduleTask(scheduledApiVo.getWfId(), scheduledApiVo.getUserId(), taskService), triggerInfo);
        }
        @Async("asyncTaskExecutor")
        public void stopScheduleds(ScheduledApiVo scheduledApiVo) {
            //移除Wfid,停止原Schedule任务
            log.warn("原数字员工["+scheduledApiVo.getWfId()+"]无效,同步停止Schedule任务");
            TaskService taskService = SpringContextUtils.getBean(TaskService.class);
            ScheduleUtil.cancel(new ScheduleTask(scheduledApiVo.getWfId(), scheduledApiVo.getUserId(), taskService));
        }
    }

    SpringContextUtils类:

    package com.merak.hyper.automation.util;
    import org.springframework.beans.BeansException;
    import org.springframework.context.ApplicationContext;
    import org.springframework.context.ApplicationContextAware;
    import org.springframework.stereotype.Component;
    /**
     * @version 1.0
     * @ClassName: SpringContextUtils
     * @description: 加载Class对象
     */
    @Component
    public class SpringContextUtils implements ApplicationContextAware {
        private static ApplicationContext applicationContext;
        @Override
        public void setApplicationContext(ApplicationContext applicationContext)
                throws BeansException {
            SpringContextUtils.applicationContext = applicationContext;
        }
        public static Object getBean(String name) {
            return applicationContext.getBean(name);
        }
        public static  T getBean(Class requiredType) {
            return applicationContext.getBean(requiredType);
        }
        public static  T getBean(String name, Class requiredType) {
            return applicationContext.getBean(name, requiredType);
        }
        public static boolean containsBean(String name) {
            return applicationContext.containsBean(name);
        }
        public static boolean isSingleton(String name) {
            return applicationContext.isSingleton(name);
        }
        public static Class getType(String name) {
            return applicationContext.getType(name);
        }
    }

    ScheduledApiVo类:

    import java.io.Serializable;
    /**
     * @version 1.0
     * @ClassName: ScheduledApiVo
     * @description: scheduled Web业务层Api传递参数Vo类
     */
    public class ScheduledApiVo implements Serializable {
        private String wfId;
        private String userId;
        private String triggerId;
        //set get 略
    }

    最终:Web端通过发送Http请求 ,调用ScheduledHelper管理类接口,实现Scheduled创建、变更、停止操作

      log.info("3:云托管更新启动数字员工操作");
      ScheduledApiVo scheduledApiVo = new ScheduledApiVo();
      scheduledApiVo.setWfId(wfId);
      scheduledApiVo.setUserId(String.valueOf(updateUserId));
      scheduledApiVo.setTriggerId(newTriggerInfo.getId());
      String webHookBody = JSON.toJSONString(scheduledApiVo);
      EmsApiUtil.SendQuartzMessage(url, "add", webHookBody);
     ******************** 分隔     ************************
      public static boolean SendQuartzMessage(String quartzUrl, String method, String webHookBody){
          boolean result = false;
          try{
              //org.apache.httpcomponents.httpclient sendPost,pom依赖如下dependency
              String resp = HttpClientUtil.sendPostByJson(quartzUrl+"/"+method, webHookBody,0);
              if( "error".equals(resp) || resp.contains("405 Not Allowed")){
                  log.error("调用任务调度中心消息发送失败,地址:"+quartzUrl);
              }
              else {
                  JSONObject jsonObject = JSON.parseObject(resp);
                  if( "200".equals(String.valueOf(jsonObject.get("code"))) ){
                      result = true;
                  }
                  else{
                      log.error("调用任务调度中心失败,msg:"+String.valueOf(jsonObject.get("msg")));
                  }
              }
          }catch (Exception e){
              log.error("调用任务调度中心失败,msg:"+e.getMessage());
          }
          return result;
      }
        
            org.apache.httpcomponents
            httpclient
            4.5.2
        
    本站声明:本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系bd@zhengruan.com
    作者最新文章
    编程开发 Schedule
    相关文章 更多
    springBoot项目常用目录有哪些
    springBoot项目常用目录有哪些

    springBoot项目常用目录springBoot项目的目录结构及名规范介绍基于SpringBoot开发时的目录结构及命名规范,通过介绍能够为你解决,在实际项目中如何规划目录结构?如何命名目录更规范?各个目录分别代表什么含义?等三个问题。目录说明servicex//项目名|-admin-ui//管理服务前端代码(一般将UI和SERVICE放到一个工程中,便于管理)|-servicex-auth//模块1|-servicex-common//模块2|-servicex-gateway//模块3|-serv

    解析SpringBoot和SpringMVC之间的异同
    解析SpringBoot和SpringMVC之间的异同

    解析SpringBoot和SpringMVC之间的异同SpringBoot和SpringMVC是Java领域中非常重要的开发框架。虽然它们都属于Spring框架的一部分,但是在使用和功能上有一些明显的区别。本文将对SpringBoot和SpringMVC进行比较,解析它们之间的异同。首先,让我们来了解一下SpringBoot。SpringBo

    探索SpringCloud和SpringBoot在微服务领域的不同应用方式
    探索SpringCloud和SpringBoot在微服务领域的不同应用方式

    近年来,随着云计算和分布式架构的兴起,微服务架构的应用越来越广泛。而SpringCloud和SpringBoot作为Java开发中的两个重要框架,对于微服务的实现起到了重要的作用。然而,很多人对于它们在微服务领域的不同应用方式还存在一定的疑惑。本文将从不同的角度探索SpringCloud和SpringBoot在微服务中的应用方式。首先,我们来了解一下Spri

    SpringBoot和SpringMVC有何区别?
    SpringBoot和SpringMVC有何区别?

    SpringBoot与SpringMVC的不同之处在哪里?SpringBoot和SpringMVC是两个非常流行的Java开发框架,用于构建Web应用程序。尽管它们经常分别被使用,但它们之间的不同之处也是很明显的。首先,SpringBoot可以被看作是一个Spring框架的扩展或者增强版。它旨在简化Spring应用程序的初始化和配置过程,以帮助开发人

    比较SpringBoot和SpringMVC的异同
    比较SpringBoot和SpringMVC的异同

    SpringBoot和SpringMVC都是Java开发中常用的框架,但它们之间有一些明显的差异。本文将探究这两个框架的特点和用途,并对它们的差异进行比较。首先,我们来了解一下SpringBoot。SpringBoot是由Pivotal团队开发的,它旨在简化基于Spring框架的应用程序的创建和部署。它提供了一种快速、轻量级的方式来构建独立的、可执行

    SpringBoot与SpringMVC的不同点是什么?
    SpringBoot与SpringMVC的不同点是什么?

    SpringBoot和SpringMVC是Java开发中常用的两个框架,它们都是由Spring框架所提供的,但在功能和使用方式上有着一些区别。本文将分别介绍SpringBoot和SpringMVC的特点和区别。一、SpringBoot的特点:简化配置:SpringBoot通过约定优于配置的原则,大大简化了项目的配置过程。它可以自动配置项目所需要的参数,开发人

    比较和选择指南:SpringCloud与SpringBoot的功能比较
    比较和选择指南:SpringCloud与SpringBoot的功能比较

    SpringCloud和SpringBoot是目前Java领域中最热门的开源框架,它们分别提供了一套完善的微服务架构和快速构建应用程序的解决方案。本文将对它们的功能进行比较,并给出选择指南,以帮助读者了解它们的优势和适用场景。SpringBoot是一个用于开发Java应用程序的框架,它提供了一个简化的开发流程,集成了大量常用的功能和组件,减少了开发者的工作量

    SpringCloud与SpringBoot:分析它们之间的相似与不同
    SpringCloud与SpringBoot:分析它们之间的相似与不同

    深入剖析SpringCloud和SpringBoot的异同引言:在构建企业级应用程序时,Spring框架已经成为开发者们的首选。它提供了一种简单而强大的方式来构建独立于平台的应用程序。Spring框架由两个核心模块组成:SpringBoot和SpringCloud。虽然它们都可以帮助开发者快速搭建应用程序,但它们的目标和用途存在一些差异。本文将深入剖析Spr

    从架构角度看SpringCloud与SpringBoot的差异
    从架构角度看SpringCloud与SpringBoot的差异

    从架构角度看SpringCloud与SpringBoot的差异引言:在当今的互联网时代,构建分布式系统已经成为了一种必要的需求。而SpringBoot和SpringCloud正是为了满足这个需求而诞生的。尽管它们都是由Spring框架所提供的解决方案,但从架构角度来看,它们存在着一些重要的差异。本文将从架构的角度出发,对SpringBoot和SpringCl

    Java API 开发中使用 SpringBoot 的利弊分析
    Java API 开发中使用 SpringBoot 的利弊分析

    JavaAPI开发中使用SpringBoot的利弊分析随着互联网的快速发展和技术的不断更新迭代,Java技术在开发中的广泛应用引起了人们的重视。而SpringBoot作为一种微服务架构的解决方案,已经逐渐成为Java开发中的热门选择。那么,在JavaAPI开发中使用SpringBoot,到底有哪些利弊呢?下面来分析一下。利:简化开发

    查看更多
    精品专题 更多
    装机必备
    装机必备

    正软商城装机必备专区,精选办公、浏览器、安全防护、影音播放、压缩解压、设计创作和系统工具等电脑常用正版软件,帮助用户快速完成新电脑软件配置。

    Windows
    Windows

    正软商城Windows软件专区,汇集适用于Windows电脑的办公、设计、安全防护、影音播放、开发工具和系统优化软件,提供软件介绍、系统要求、正版授权及购买下载服务。

    PDF教程
    PDF教程

    正软商城PDF教程频道提供PDF编辑、转换、合并、拆分、压缩及格式处理方法,同时介绍常用PDF软件和工具的使用技巧。

    Mac软件 更多
    讯飞智作 网页版
    讯飞智作 网页版
    Windows/ macOS/ Linux

    讯飞智作是一款基于语音合成技术、虚拟人驱动技术与数字人形象声音构建能力的 AI 数字人音视频创作平台。

    火山引擎 网页版
    火山引擎 网页版
    Windows/ macOS/ Linux

    火山引擎是字节跳动旗下企业级云与AI服务平台。聚焦大模型核心能力,依托字节自研豆包多模态大模型,凭借火山方舟一站式平台,提供模型精调、推理部署、智能应用搭建等全链路服务,结合高性能AI算力,助力各行业快速落地大模型数字化与智能化应用。

    Aperty macOS版
    Aperty macOS版
    macOS

    Aperty 是 Skylum 推出的 AI 人像修图软件,支持自然肤质修饰、瑕疵处理、面部与身体调整、预设及批量同步。

    WINDOWS 更多
    讯飞智作 网页版
    讯飞智作 网页版
    Windows/ macOS/ Linux

    讯飞智作是一款基于语音合成技术、虚拟人驱动技术与数字人形象声音构建能力的 AI 数字人音视频创作平台。

    火山引擎 网页版
    火山引擎 网页版
    Windows/ macOS/ Linux

    火山引擎是字节跳动旗下企业级云与AI服务平台。聚焦大模型核心能力,依托字节自研豆包多模态大模型,凭借火山方舟一站式平台,提供模型精调、推理部署、智能应用搭建等全链路服务,结合高性能AI算力,助力各行业快速落地大模型数字化与智能化应用。

    PixTV 网页版
    PixTV 网页版
    Windows

    PixTV 是一款在浏览器中使用的 AI 视觉内容创作平台,提供图片、视频、音频、文字生成、AI 分镜、局部重绘、提示词反推和无限画布等工具,适合短剧、漫剧、广告及社交媒体内容制作。