spring cloud笔记5

spring cloud config简介:

架构图:

映射规则:

1.

c.c.c.ConfigServicePropertySourceLocator : Fetching config from server at: http://localhost:8888
c.c.c.ConfigServicePropertySourceLocator : Could not locate PropertySource: I/O error on GET request for "http://localhost:8888/foobar/dev/master": Connection refused: connect; nested exception is java.net.ConnectException: Connection refused: connect
 c.itmuch.cloud.ConfigServerApplication   : No active profile set, falling back to default profiles: default

application.yml

server:
  port: 8081
spring:
  cloud:
    config:
      uri: http://localhost:8080
      profile: dev
      label: master   # 当configserver的后端存储是Git时,默认就是master
  application:
    name: foobar
   解析:

 bootstrap.*里面的配置先加载  ——>连接config service, 加载远程配置(git仓库里面的配置)  ——>加载application.*里面的配置

解决方法:

新建文件bootstrap.yml

spring:
  cloud:
    config:
      uri: http://localhost:8080
      profile: dev
      label: master 
  application:
    name: foobar
    2.尽量不要把@RefreshScope和@Configuration放在一起使用
   

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
很高兴能够为你提供关于Spring Cloud笔记Spring Cloud是一套基于Spring Boot的微服务框架,它提供了一系列开箱即用的工具和组件,帮助开发者快速构建和部署分布式系统。下面是一些关键的笔记要点: 1. 服务注册与发现:Spring Cloud提供了Eureka、Consul和Zookeeper等注册中心,用于服务的注册与发现,实现了服务之间的自动发现和负载均衡。 2. 服务调用:通过Spring Cloud的RestTemplate或Feign客户端,可以轻松实现服务之间的远程调用。Feign还支持声明式的服务调用,简化了代码的编写。 3. 负载均衡:Spring Cloud提供了Ribbon和LoadBalancer等组件,用于实现负载均衡。通过配置负载均衡策略,可以将请求分发到不同的服务实例上。 4. 服务容错:通过Hystrix或Sentinel等组件,可以实现服务的容错和熔断。当某个服务不可用时,可以快速失败或者返回默认值,保证整个系统的稳定性。 5. 配置中心:Spring Cloud Config提供了集中式的配置管理,可以将配置文件集中存储在Git、SVN等版本控制系统中,并实现配置文件的动态刷新。 6. 链路追踪:通过Spring Cloud Sleuth或Zipkin等工具,可以实现分布式系统的链路追踪和监控。可以了解每个请求经过的各个服务节点,便于排查和解决问题。 7. 消息驱动:Spring Cloud Stream和Spring Cloud Bus等组件,提供了消息驱动的方式来实现服务之间的解耦和异步通信。 这只是对Spring Cloud的一些简单介绍,希望能够帮助到你。如果有具体的问题或者需要进一步的资料,请随时提问。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值