Spring Cloud配置中心遇到No spring.config.import set问题

错误提示:

Application failed to start due to an exception
org.springframework.cloud.config.client.ConfigServerConfigDataMissingEnvironmentPostProcessor$ImportException: No spring.config.import set

建议的解决方案:

***************************
APPLICATION FAILED TO START
***************************
Description:
No spring.config.import property has been defined
Action:
Add a spring.config.import=configserver: property to your configuration.
	If configuration is not required add spring.config.import=optional:configserver: instead.
	To disable this check, set spring.cloud.config.enabled=false or 
	spring.cloud.config.import-check.enabled=false.

解决方案

  1. 在server端配置git地址
server:
 port: 8003
spring:
 application:
   name: config-server #应用名称,别名
 cloud:
   config:
     server:
       git:
         uri: git仓库的地址
         search-paths: 搜索路径
         default-label: 分支
  1. 在client端新建一个bootstrap.properties(bootstrap.yml)文件
server.port=8004
spring.profiles.active=dev
spring.application.name=config-client

spring.cloud.config.discovery.enabled=true
spring.cloud.config.discovery.service-id=config-server
spring.config.import=optional:configserver:http://localhost:8003
spring.cloud.config.name=${spring.application.name}
spring.cloud.config.profile=${spring.profiles.active}

就是这样了。。。

评论:

**用户ToDoMyBest6534**:我也遇到这个问题,我看了官网,原来springcloud2020 版本 把Bootstrap被默认禁用,
同时spring.config.import加入了对解密的支持。对于Config Client、Consul、Vault和Zookeeper的配置导入,
如果你需要使用原来的配置引导功能,
那么需要将org.springframework.cloud:spring-cloud-starter-bootstrap依赖引入到工程中
评论 15
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值