jenkins发布服务失败查看catalina.out启动日志和xxl-job jobhandler naming conflicts

2024-10-09 11:21:48 浏览数 (5)

jenkins发布服务失败查看catalina.out启动日志和xxl-job jobhandler naming conflicts

1.查看tomcat/logs/catalina.out 日志,发现和定位问题: Error starting ApplicationContext. To display the auto-configuration report re-run your application with 'debug' enabled. 2024-04-26 13:55:36.872 [localhost-startStop-1][orderCoreApi,,,] ERROR o.s.boot.SpringApplication#reportFailure [line:771] - Application startup failedorg.springframework.beans.factory.BeanCreationException: Error creating bean with name 'xxlJobExecutor' defined in class path resource [com/myProject/xxljob/XxlJobConfiguration.class]: Invocation of init method failed; nested exception is java.lang.RuntimeException: xxl-job jobhandler naming conflicts.

Caused by: java.lang.RuntimeException: xxl-job jobhandler naming conflicts.

2.如下代码,如果项目中存在“mySendSmsJobTask”重复,则会在项目启动的时候,报以上错误。

代码语言:javascript复制
@Component
@JobHandler("mySendSmsJobTask")
public class MySendSmsJobTask extends IJobHandler {
    private Logger logger = LoggerFactory.getLogger(MySendSmsJobTask.class);

    @Override
    public ReturnT<String> execute(String s) throws Exception {
        Transaction t = Cat.getProducer().newTransaction(CatConstants.XXL_JOB_CALL, "定时查询 定时任务发送短信 定时任务");
        try {
            Cat.logEvent(CatConstants.XXL_JOB_METHOD,"MySendSmsJobTask.execute");
            Cat.logEvent(CatConstants.XXL_JOB_PARAM,null);
            logger.info("开始执行 定时任务发送短信  定时器");
            XxlJobLogger.log("开始执行 定时任务发送短信 定时器");

            //定时任务业务逻辑处理
            
            logger.info("结束执行 定时任务发送短信 ");
            XxlJobLogger.log("结束执行 定时任务发送短信 ");
            t.setStatus(Transaction.SUCCESS);
            return SUCCESS;
        } catch (Exception e) {
            XxlJobLogger.log("执行 定时任务发送短信 异常:"   e);
            logger.error("执行 定时任务发送短信 异常",e);
            Cat.logError("执行 定时任务发送短信 异常",e);
            t.setStatus(e);
            return new ReturnT(FAIL.getCode(),e.toString());
        } finally {
            if (t != null) {
                t.complete();
            }
        }
    }
}

1 人点赞