# springCloud **Repository Path**: sunpp125/springCloud ## Basic Information - **Project Name**: springCloud - **Description**: 入门Demo - **Primary Language**: Java - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2018-06-28 - **Last Updated**: 2020-12-18 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # Spring Cloud Examples Spring Cloud是一系列框架的有序集合。它利用Spring Boot的开发便利性巧妙地简化了分布式系统基础设施的开发,如服务发现注册、配置中心、消息总线、负载均衡、断路器、数据监控等,都可以用Spring Boot的开发风格做到一键启动和部署。Spring并没有重复制造轮子,它只是将目前各家公司开发的比较成熟、经得起实际考验的服务框架组合起来,通过Spring Boot风格进行再封装屏蔽掉了复杂的配置和实现原理,最终给开发者留出了一套简单易懂、易部署和易维护的分布式系统开发工具包 以下为Spring Cloud的核心功能: 分布式/版本化配置 服务注册和发现 路由 服务和服务之间的调用 负载均衡 断路器 分布式消息传递 # Spring Cloud 工具框架 1、Spring Cloud Config 配置中心,利用git集中管理程序的配置。 2、Spring Cloud Netflix 集成众多Netflix的开源软件 3、Spring Cloud Bus 消息总线,利用分布式消息将服务和服务实例连接在一起,用于在一个集群中传播状态的变化 4、Spring Cloud for Cloud Foundry 利用Pivotal Cloudfoundry集成你的应用程序 5、Spring Cloud Cloud Foundry Service Broker 为建立管理云托管服务的服务代理提供了一个起点。 6、Spring Cloud Cluster 基于Zookeeper, Redis, Hazelcast, Consul实现的领导选举和平民状态模式的抽象和实现。 7、Spring Cloud Consul 基于Hashicorp Consul实现的服务发现和配置管理。 8、Spring Cloud Security 在Zuul代理中为OAuth2 rest客户端和认证头转发提供负载均衡 9、Spring Cloud Sleuth SpringCloud应用的分布式追踪系统,和Zipkin,HTrace,ELK兼容。 10、Spring Cloud Data Flow 一个云本地程序和操作模型,组成数据微服务在一个结构化的平台上。 11、Spring Cloud Stream 基于Redis,Rabbit,Kafka实现的消息微服务,简单声明模型用以在Spring Cloud应用中收发消息。 12、Spring Cloud Stream App Starters 基于Spring Boot为外部系统提供spring的集成 13、Spring Cloud Task 短生命周期的微服务,为SpringBooot应用简单声明添加功能和非功能特性。 14、Spring Cloud Task App Starters 15、Spring Cloud Zookeeper 服务发现和配置管理基于Apache Zookeeper。 16、Spring Cloud for Amazon Web Services 快速和亚马逊网络服务集成。 17、Spring Cloud Connectors 便于PaaS应用在各种平台上连接到后端像数据库和消息经纪服务。 18、Spring Cloud Starters (项目已经终止并且在Angel.SR2后的版本和其他项目合并) 19、Spring Cloud CLI 插件用Groovy快速的创建Spring Cloud组件应用。 # [eureka-producer-consumer] spring-cloud-eureka 注册中心 @EnableEurekaServer 单击模式 集群模式(初始化服务,相互注册) spring-cloud-producer 服务提供者 @EnableDiscoveryClient 注册服务 spring-cloud-consumer 服务消费者 @EnableDiscoveryClient @EnableFeignClients 远程调用 {name=""} 定义远程接口 spring-cloud-consumer-hystricx 消费者熔断 @EnableDiscoveryClient @EnableFeignClients 远程调用 {name="",fallback=".class"} 实现远程接口 application添加 feign.hystrix.enabled=true hystrix-dashboard-turbine 熔断服务监测 消费者添加@EnableCircuitBreaker @EnableHystrixDashboard @EnableTurbine application添加 turbine.appConfig=spring-cloud-consumer1,spring-cloud-consumer2 turbine.aggregator.clusterConfig= default turbine.clusterNameExpression= new String("default") #[spring-cloud-config-git] spring-cloud-config-server 配置中心Git托管 @EnableConfigServer 启动config服务 application添加Git配置 spring-cloud-config-client 配置调用者 添加配置文件bootstap spring-cloud-eureka 集群化配置 负载均衡 #[spring-cloud-config-eureka-bus] spring-cloud-config-server 配置中心Git托管 @EnableConfigServer 启动config服务 application添加Git配置 spring-cloud-config-client 配置调用者 添加配置文件bootstap 获取最新配置信息 以MQ进行异步通知 spring-cloud-eureka 集群化配置 负载均衡 #[gateway-service-zuul] gateway-service-zuul-eureka 启动zuul @EnableZuulProxy 启动zuul服务 自定义路由规则 zuul.routes.producer.path=/producer/** zuul.routes.producer.serviceId=spring-cloud-producer #[spring-cloud-zuul] spring-cloud-zuul ZuulFilter 实现接口自定义拦截 pre routing post error FallBack 实现接口自定义服务异常处理 服务级别 Hystircx 接口级别 自定义异常 #[spring-cloud-sleuth-zipkin] zipkin-server @EnableEurekaClient @EnableZipkinServer 启动zipkin 链路调用 相关服务添加配置 zipkin: base-url: http://localhost:9000 服务器 sleuth: sampler: percentage: 1.0 样本采集比例 参考博文 http://www.ityouknow.com/springcloud