springboot1.5升级到2.X 导致config-server报错

本文分析了Spring Cloud配置中心启动时出现的依赖注入错误,提供了详细的配置调整方案以解决NullPointerException异常,包括去除basedir配置项。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name ‘org.springframework.cloud.config.server.config.CompositeConfiguration’: Unsatisfied dependency expressed through method ‘setEnvironmentRepos’ parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘defaultEnvironmentRepository’ defined in class path resource [org/springframework/cloud/config/server/config/DefaultRepositoryConfiguration.class]: Invocation of init method failed; nested exception is java.lang.NullPointerException

解决:

server:
  port: 8769
spring:
  application:
    name: config-server

  cloud:
    config:
      server:
        git:
          uri: 
          search-paths: /*.properties
          username: 
          password: 
          basedir: /
          default-label: master

springboot2 如果有 basedir: / 就会报错。去掉就好了。
原因:待查

C:\Users\20151\Desktop\build_server\server\blcx-center>java -Djdk.attach.allowAttachSelf=true -jar blcx-center.jar WARNING: sun.reflect.Reflection.getCallerClass is not supported. This will impact performance. 2025-06-24 15:20:06,253 main ERROR Unrecognized format specifier [z] 2025-06-24 15:20:06,257 main ERROR Unrecognized conversion specifier [z] starting at position 28 in conversion pattern. 15:20:06.376 [main] INFO com.xkhy.blcx.BlcxCenterMain - 根目录:C:\Users\20151\Desktop\build_server\server\blcx-center\ 15:20:06.376 [main] INFO com.xkhy.blcx.BlcxCenterMain - 运行目录:C:\Users\20151\Desktop\build_server\server\blcx-center 15:20:06.376 [main] INFO com.xkhy.blcx.BlcxCenterMain - 初始化【Properties】.......................start 15:20:06.378 [main] INFO com.xkhy.blcx.BlcxCenterMain - 初始化【Properties】.......................end 15:20:06.378 [main] INFO com.xkhy.blcx.BlcxCenterMain - 初始化【热部署】.......................start 15:20:06.381 [main] ERROR com.cca.core.config.print.SystemPrintStream - java.lang.Exception: jar文件不存在[blcx-center/lib/cca-agent-0.0.1.jar] 15:20:06.381 [main] ERROR com.cca.core.config.print.SystemPrintStream - at org.cca.agent.AgentManage.init(AgentManage.java:41) 15:20:06.381 [main] ERROR com.cca.core.config.print.SystemPrintStream - at org.cca.agent.AgentManage.init(AgentManage.java:106) 15:20:06.381 [main] ERROR com.cca.core.config.print.SystemPrintStream - at com.xkhy.blcx.BlcxCenterMain.lambda$init$4(BlcxCenterMain.java:169) 15:20:06.381 [main] ERROR com.cca.core.config.print.SystemPrintStream - at com.xkhy.blcx.BlcxCenterMain.initItem(BlcxCenterMain.java:146) 15:20:06.382 [main] ERROR com.cca.core.config.print.SystemPrintStream - at com.xkhy.blcx.BlcxCenterMain.init(BlcxCenterMain.java:168) 15:20:06.382 [main] ERROR com.cca.core.config.print.SystemPrintStream - at com.xkhy.blcx.BlcxCenterMain.start(BlcxCenterMain.java:90) 15:20:06.382 [main] ERROR com.cca.core.config.print.SystemPrintStream - at com.xkhy.blcx.BlcxCenterMain.main(BlcxCenterMain.java:57) 15:20:06.388 [main] INFO com.xkhy.blcx.BlcxCenterMain - 初始化【热部署】.......................end 15:20:06.388 [main] INFO com.xkhy.blcx.BlcxCenterMain - 初始化【数据库连接池】.......................start 15:20:06.404 [main] INFO com.zaxxer.hikari.HikariDataSource - HikariPool-1 - Starting... 15:20:06.906 [main] INFO com.zaxxer.hikari.HikariDataSource - HikariPool-1 - Start completed. 15:20:06.906 [main] INFO com.xkhy.blcx.BlcxCenterMain - 初始化【数据库连接池】.......................end 15:20:06.907 [main] INFO com.xkhy.blcx.BlcxCenterMain - 初始化【获取开服时间】.......................start 15:20:06.931 [main] ERROR com.cca.core.config.print.SystemPrintStream - Exception in thread "main" 15:20:06.931 [main] ERROR com.cca.core.config.print.SystemPrintStream - java.lang.NullPointerException: Cannot invoke "com.xkhy.blcx.domain.model.center.sysConfig.SysConfig.getValue()" because the return value of "com.xkhy.blcx.domain.model.center.sysConfig.dao.SysConfigDao.selectByKey(String)" is null 15:20:06.931 [main] ERROR com.cca.core.config.print.SystemPrintStream - at com.xkhy.blcx.config.CoreConfig.initStartDate(CoreConfig.java:61) 15:20:06.931 [main] ERROR com.cca.core.config.print.SystemPrintStream - at com.xkhy.blcx.BlcxCenterMain.lambda$init$6(BlcxCenterMain.java:179) 15:20:06.931 [main] ERROR com.cca.core.config.print.SystemPrintStream - at com.xkhy.blcx.BlcxCenterMain.initItem(BlcxCenterMain.java:146) 15:20:06.931 [main] ERROR com.cca.core.config.print.SystemPrintStream - at com.xkhy.blcx.BlcxCenterMain.init(BlcxCenterMain.java:178) 15:20:06.931 [main] ERROR com.cca.core.config.print.SystemPrintStream - at com.xkhy.blcx.BlcxCenterMain.start(BlcxCenterMain.java:90) 15:20:06.931 [main] ERROR com.cca.core.config.print.SystemPrintStream - at com.xkhy.blcx.BlcxCenterMain.main(BlcxCenterMain.java:57)
最新发布
06-25
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值