springboot整合elaticjob报错

Invocation of init method failed; nested exception is org.springframework.core.NestedIOException: Fa Invocation of init method failed; nested exception is org.springframework.core.NestedIOException: Failed to parse mapping resource: ‘file [C:\Users\82784\IdeaProjects\spring-study\spring-10-mybatis\target\classes\com\fj\dao\UserMapper.xml]’; IllegalArgumen 阅读详情

在这里插入图片描述
springboot整合elaticjob报错 Invocation of init method failed; nested exception is java.lang.NullPointerException

application.properties文件配置
elaticjob.zookeeper.server-lists=10.10.80.51:2181
elaticjob.zookeeper.namespace=my-project
server.port=8766
spring.application.name=scheduler-service

zookeeper注册中心

spring.elasticjob.serverList = 10.10.80.51:2181
spring.elasticjob.namespace = elastic-job-lite-springboot

stockJob.cron = 0/5 * * * * ?
stockJob.shardingTotalCount = 2
stockJob.shardingItemParameters = 0=Chengdu0,1=Chengdu1

stockSimpleJob.java文件
package com.example.elasticjob.job;

import com.dangdang.ddframe.job.api.ShardingContext;
import com.dangdang.ddframe.job.api.simple.SimpleJob;
import org.springframework.stereotype.Component;

@Component
public class StockSimpleJob implements SimpleJob {

@Override
public void execute(ShardingContext shardingContext) {
    System.out.println(String.format("------Thread ID: %s, 任务总片数: %s, " +
                    "当前分片项: %s.当前参数: %s,"+
                    "当前任务名称: %s.当前任务参数: %s"
            ,
            Thread.currentThread().getId(),
            shardingContext.getShardingTotalCount(),
            shardingContext.getShardingItem(),
            shardingContext.getShardingParameter(),
            shardingContext.getJobName(),
            shardingContext.getJobParameter()

    ));

}

}
config配置类JobRegistryCenterConfig
package com.example.elasticjob.config;

import com.dangdang.ddframe.job.reg.zookeeper.ZookeeperConfiguration;
import com.dangdang.ddframe.job.reg.zookeeper.ZookeeperRegistryCenter;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
@ConditionalOnExpression("’${spring.elasticjob.serverList}’.length() > 0") //判断是否配置了zookeeper 地址
public class JobRegistryCenterConfig {

@Bean(initMethod = "init")
public ZookeeperRegistryCenter regCenter(@Value("${spring.elasticjob.serverList}") final String serverList, @Value("${spring.elasticjob.namespace}") final String namespace) {
    return new ZookeeperRegistryCenter(new ZookeeperConfiguration(serverList, namespace));
}

}
SpringJobScheduler.java

package com.example.elasticjob.config;

import com.dangdang.ddframe.job.api.simple.SimpleJob;
import com.dangdang.ddframe.job.config.JobCoreConfiguration;
import com.dangdang.ddframe.job.config.simple.SimpleJobConfiguration;
import com.dangdang.ddframe.job.lite.api.JobScheduler;
import com.dangdang.ddframe.job.lite.config.LiteJobConfiguration;
import com.dangdang.ddframe.job.lite.spring.api.SpringJobScheduler;
import com.dangdang.ddframe.job.reg.zookeeper.ZookeeperRegistryCenter;
import com.example.elasticjob.job.StockSimpleJob;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
class StockJobConfig {
@Autowired
private JobRegistryCenterConfig jobRegistryCenterConfig;
@Autowired
private ZookeeperRegistryCenter regCenter;
public StockJobConfig() {
}
@Bean(initMethod = “init”)
public JobScheduler simpleJobScheduler(final StockSimpleJob simpleJob, @Value("stockJob.cron")finalStringcron,@Value("{stockJob.cron}") final String cron, @Value("stockJob.cron")finalStringcron,@Value("{stockJob.shardingTotalCount}") final int shardingTotalCount,
@Value("${stockJob.shardingItemParameters}") final String shardingItemParameters) {
return new SpringJobScheduler(simpleJob, regCenter, simpleJobConfigBuilder(simpleJob.getClass(), cron, shardingTotalCount, shardingItemParameters));
}
/**
*@Description 任务配置类
*/
private LiteJobConfiguration simpleJobConfigBuilder(final Class<? extends SimpleJob> jobClass,
final String cron,
final int shardingTotalCount,
final String shardingItemParameters){

    return LiteJobConfiguration
            .newBuilder(
                    new SimpleJobConfiguration(
                            JobCoreConfiguration.newBuilder(
                                    "my-jobName",cron,shardingTotalCount)
                                    .shardingItemParameters(shardingItemParameters).jobParameter("job-参数")
                                    .build()
                            ,jobClass.getCanonicalName()
                    )
            )
            .overwrite(true)
            .build();
}
/**
 * 动态添加
 * @param jobClass
 * @param cron
 * @param shardingTotalCount
 * @param shardingItemParameters
 */
public void addSimpleJobScheduler(final Class<? extends SimpleJob> jobClass,
                                  final String cron,
                                  final int shardingTotalCount,
                                  final String shardingItemParameters){
    JobCoreConfiguration coreConfig = JobCoreConfiguration.newBuilder(jobClass.getName(), cron, shardingTotalCount).shardingItemParameters(shardingItemParameters).build();
    SimpleJobConfiguration simpleJobConfig = new SimpleJobConfiguration(coreConfig, jobClass.getCanonicalName());
    JobScheduler jobScheduler = new JobScheduler(regCenter, LiteJobConfiguration.newBuilder(simpleJobConfig).build());
    jobScheduler.init();
}

}

pom

<?xml version="1.0" encoding="UTF-8"?>


4.0.0

org.springframework.boot
spring-boot-starter-parent
2.2.2.RELEASE


com.example.elasticjob
elasticjob
0.0.1-SNAPSHOT
elasticjob
Demo project for Spring Boot

<java.version>1.8</java.version>



org.springframework.boot
spring-boot-starter-web



com.github.kuhn-he
elastic-job-lite-spring-boot-starter
2.1.5



com.dangdang
elastic-job-lite-core
2.1.5


com.dangdang
elastic-job-lite-spring
2.1.5

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-devtools</artifactId>
        <scope>runtime</scope>
        <optional>true</optional>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-test</artifactId>
        <scope>test</scope>
    </dependency>
</dependencies>

<build>
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
        </plugin>
    </plugins>
</build>

麻烦大神帮我看下 到底是什么错误??!!!

eNSP无法启动AR报错码40,而且按照eNSP帮助手册排查都没用,我的处理方法【自己存档版】 阅读详情

相关推荐

NIST随机性测试实战:从理论公式到结果解读

本文详细解析了NIST随机性测试的实战应用,从基础测试到高级测试,涵盖频数测试、块频数测试、游程测试等核心方法。通过实际案例和参数设置经验,帮助读者理解如何解读测试结果并排查常见问题,提升随机数生成质量。文章还分享了自动化测试流程和硬件RNG特殊处理技巧,适合密码学和区块链开发者参考。

weixin_29323365的博客 314

Mybatis plus 启动项目时报错Invocation of init method failed; nested exception is java.lang.NullPointerExcep

Mybatis plus 启动项目时报错Invocation of init method failed; nested exception is java.lang.NullPointerException

guoquanqin的博客 1万+

别再乱选WiFi信道了!手把手教你用WiFi Analyzer优化2.4G/5G家庭网络(附避坑指南)

本文详细介绍了如何使用WiFi Analyzer工具优化家庭WiFi网络,解决2.4GHz和5GHz信道的冲突问题。通过分析信道拥堵原因、提供安装使用指南及优化策略,帮助用户显著提升网络速度与稳定性,特别适合密集住宅区和多设备家庭。

weixin_42665725的博客 5871

Error creating bean with name 'schedule': Invocation of init method failed; nested exception is java...

这个错误消息表明在创建一个名为 "schedule" 的 bean 时出现了错误,具体是在调用 bean 的初始化方法时发生了空指针异常。 空指针异常是 Java 程序设计中常见的异常,通常表示程序试图在没有初始化或赋值的对象上调用方法或访问属性。在这种情况下,可能是因为在初始化 bean 时,程序试图调用了未初始化的对象的方法或访问未初始化的对象的属性。 解决这个问题的方法是找出空指针异常发生的...

weixin_42608318的博客 1万+

【OpenBMC 系列】4.启动流程 使用qume模拟ast2600-evb

1.安装openbmc适配的qume 2.启动bmc 3.使用bmc web

AiFool的博客 4458

经典脉冲激光测距原理&雷达方程

脉冲激光测距机的工作过程如下:首先用瞄准光学系统瞄准目标,然后接通激光电源,储能电容器充电,产生触发闪光灯的触发脉冲,闪光灯点亮,激光器受激辐射,从输出反射镜发射出一个前沿陡峭、峰值功率高的激光脉冲,通过发射光学系统压缩光束发射角后射向目标。通过计算激光发射功率经介质传输的衰减,目标表面截获和反射的光功率,到达接收视场的光功率,以及接收光学系统接收到的光功率,就可以得到到达光电探测器的光功率,即接收功率。⑤光東路程上的折射率变化;),测量光脉冲到达目标并由目标返回到接收机的时间,由此计算出目标的距离。

weixin_46153372的博客 2520

Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError翻一下

"Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError" 这句话的意思是 "调用初始化方法失败;嵌套异常是java.lang.NoClassDefFoundError"。 在 Java 编程语言中,NoClassDefFoundError 是一种错误,表示 Java 虚拟机无法找到应...

weixin_42584586的博客 1万+

Cadence Spectre仿真保姆级教程:从DC/AC到PSS/PV,手把手教你搞定模拟电路分析

作为业界标准的Cadence Spectre仿真器,以其精确的算法和丰富的分析类型,成为每个模拟IC工程师必须掌握的利器。本文将带你从零开始,系统掌握Spectre仿真的核心技能,从最基础的DC工作点分析到复杂的PSS相位噪声仿真,每个步骤都配有详细的操作指导和实用技巧。记得我第一次使用Spectre仿真一个简单的两级运放时,花了整整三天时间才得到正确的AC响应曲线。过程中踩过的坑、浪费的时间,现在想来都是宝贵的学习资源。与传统的AC分析不同,STB分析可以在不破坏环路的情况下评估稳定性。

weixin_30898555的博客 325

第五章 -分布式定时任务框架ElasticJob之SpringBoot整合SimpleJob作业(实战二)

上一节我们实现了zookeeper注册中心自动装配,本节我们介绍SimpleJob作业如何自动注册进JobScheduler,并启动SpringBoot时让定时任务跑起来。

qq_40187702的博客 2583

RK3588网络调试笔记:当我把默认RTL8211F PHY换成另一款时,踩了哪些坑?

本文详细记录了在RK3588平台上将默认RTL8211F PHY芯片替换为其他型号的全过程,包括硬件设计验证、内核驱动适配、复位时序配置等关键步骤。通过实际案例分享,提供了从驱动调试到硬件优化的系统性解决方案,帮助开发者高效完成PHY芯片替换,确保网络接口稳定性。

weixin_30291791的博客 669

10、犹豫双模糊TOPSIS算法:原理与实例解析

本文介绍了犹豫双模糊TOPSIS算法的基本原理与应用步骤,结合中国四家纺织公司的案例,详细解析了从构建犹豫双模糊决策矩阵、归一化处理、专家信息聚合,到确定正负理想解、计算距离与相对贴近度系数的完整决策流程。该方法有效应对决策者在评价过程中的犹豫性,适用于财务评估、项目选择等复杂多属性决策场景,具有较强的实用性和推广价值。

yhn45678901的博客 121

Springboot 分布式定时任务 ElasticJob-Lite 3.0 配置和整合

Springboot 分布式定时任务 ElasticJob-Lite 3.0 配置和使用 ElasticJob用于解决springboot的定时任务 @EnableScheduling 集群部署产生的冲突 本文基于yml配置文件和注解启动分布式定时任务 中文官方文档 中文官方文档 版本依赖 JAVA 请使用 Java 8 及其以上版本。 Maven 请使用 Maven 3.5.0 及其以上版本。 ZooKeeper 请使用 ZooKeeper 3.6.0 及其以上版本。 控制台页面

weixin_44008257的博客 4686

2025年GESP12月认证C++一级真题解析

摘要 本文包含13道C++编程选择题,每题2分,涉及语法、运算符、循环、条件判断等知识点。题目考察了变量命名规则、运算符优先级、赋值语句、循环控制、格式化输出等内容。部分题目解析与标答存在差异,例如第4题逗号表达式输出应为5但标答为4,第6题赋值运算结果应为4 4但标答为3 4等。这些题目适合用于检验基础编程能力,但需注意部分标答可能存在争议,建议结合具体编译环境验证。最后一题考察"漂亮数"判断,要求填写数字某位能被3整除的条件表达式。

lan_in的博客 741

springboot整合 elasticjob 3.x 启动报错 Error creating bean with name zookeeperRegistryCenter

pom文件添加,指定版本, 5.1.0为高版本spring-boot-starter-parent推荐的版本。版本太低,无法推荐到合适的。

LiZhen314的博客 1125

最新的sdio 4.0 spec 协议标准 带书签 高清完整PDF版

Part-E1-SDIO-Specification-Ver4.00-Final-120220.pdf:最新的sdio 4.0 spec 协议标准 带书签 高清完整PDF版,包括SDIO 接口的外设,SDIO 接口官方协议等。

visio安装包

Microsoft Office Visio 是一款专业的制图软件。利用经过更新的形状、协作工具和数据链接图表,创建专业级图表以简化复杂的信息。

SpringBoot集成系列--ElasticJob

本文介绍了ElasticJob在Spring Boot中的集成步骤,包括添加依赖、配置ElasticJob和定义具体的作业。同时,还介绍了ElasticJob-UI、Elastic-Job的分片理解和其原理。

程序员Forlan的博客 2324

廖雪峰Python教程[完整版]

廖雪峰的python教程整理的,已经排好版了,而且还是完整的,适合小白

ElasticJob启动报错:java.lang.ClassNotFoundException: com.fasterxml.jackson.core.TSFBuilder

遇到类似的问题,没有头绪的时候,就比对着还原,然后一步步添加,虽然是个笨办法,但是也能收到好的效果。

ql_gome的博客 1550

Probability and Statistics - 4th edition

Probability and Statistics - 4th edition

【项目问题解决】springboot本机启动elasticjob抛出异常HostException(ip is null)

[TOC](springboot本机启动elasticjob抛出异常HostException(ip is null))文章所属专区。

qq_43238568的博客 1429

使用ElasticJob时报错:OperationTimeoutException: KeeperErrorCode = OperationTimeout

最近在搭建ElasticJob使用环境时发现一个报错,提示zookeeper连接失败。明明yml里配置的zookeeper地址是正确的,但就是连不上。查阅相关文档和各种尝试后终于找到了问题原因。原来是因为默认连接zookeeper的时间太短了,zookeeper还没响应这边就提示报错。加上重试的间隔时间配置后,重启项目就可以正常启动了。以下是本例使用的依赖版本。

qq_42068856的博客 1231

JAVA redis缓存过期_失效java服务器

Java 并发/多线程教程——4并发模型本系列译自jakob jenkov的Java并发多线程教程(本章节部分内容参考http://ifeve.com/并发编程模型),个人觉得很有收获。由于个人水平有限,不对之处还望矫正!并发系统可以有多种并发模型来实现,并发模型指定线程如何协同完成分配...文章为什么而活2017-06-261212浏览量Hibernate 常见异常异常信息:java.net.S...

weixin_29898627的博客 357

springboot集成elasticjob定时任务及冲突解决

最近项目中要从之前的springtask框架改成用elasticjob,经过一番探索,总算成功搞定。现在做下记录: 1、引入maven的jar包依赖: <!-- 引入elastic-job 模块 --> <dependency> <groupId>org.apache.shardingsphere.elasticjob</groupId> <artifactId>elasti..

YANGYYID的博客 2097

springboot 集成 ElasticJob 定时任务出现错误:java.lang.NoSuchMethodError: com.google.common.util.concurr

这个大神的一篇博客很详细 https://blog.csdn.net/ypp91zr/article/details/84794582 情况差不多,也是出现冲突:Guava冲突 在使用ElasticJob 定时任务,出现该问题。 导入的依赖文件是 <dependency> <groupId>com.github.yinjihuan</groupId> <artifactId>elastic-j...

LittelCai的博客 1338

spingboot异步接口开发

@SpringBootApplication //开启线程的注解 @EnableAsync public class PushServiceApplication { public static void main(String[] args) { new SpringApplicationBuilder(PushServiceApplication.class).r...

free的博客 619

Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: Property报错

java, springboot, springcloud里的报错,有关于@MapperScan和@ComponentScan的操作,Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: Property报错

soulwirter的博客 3万+

Invocation of init method failed nested exception is java lang IllegalState

项目出现Invocation of init method failed; nested exception is java.lang.IllegalState 报错可能是你的Controller里面的方法@RequestMapper注解里面的路径出现重复或者xml配置文件sql语句id重复了。不限同一个类里面,可能在两个Controller类里面有相同的路径,xml文件也一样 ...

qq_39115632的博客 6万+

【Error】RequestMapping导致的500: Invocation of init method failed; nested exception is java.lang.

RequestMapping annotation的值设置错误,导致tomcat 500。 解决办法: @RequestMapping(value="/r1", method=RequestMethod.GET) @RequestMapping(path="/r2", method=RequestMethod.GET) 可以用value或者path,不能用name 错误日志: 类型 异常报告 消息 Servlet[springmvc]的Servlet.init()引发异常 描述 服.

think_ycx的专栏 4274
无奈,想逃
博客等级 码龄7年 0粉丝 1原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值