springcloud笔记


立即下载 Fire ming
2025-01-29
注册 发现 配置 Eureka 注解 依赖 Spring Client Enable Discovery
37 KB

zuul网关:
需要依赖:
Eureka-client、zuul
需要注解:
入口类:@EnableZuulProxy
需要配置:
Eureka注册与发现
转发配置
zuul.routes.api-a.path=/api-a/**
zuul.routes.api-a.serviceId=HELLO-SERVICE
Eureka注册与发现:
需要依赖:
Eureka-server
需要注解:
入口类:@EnableEurekaServer
需要配置:
Eureka注册与发现,形成高可用注册中心
生产者:
需要依赖:
spring-cloud-starter-eureka
需要注解:
入口类:@EnableDiscoveryClien
需要配置:
Eureka注册与发现
消费者Ribbon:
需要依赖:
spring-cloud-starter-eureka
Ribbon
需要注解:
@SpringCloudApplication
相当于
@SpringBootApplication
@EnableDiscoveryClient 注册与发现
@EnableCircuitBreaker 断路器
需要配置:
Eureka注册与发现
代码实现:
使用restTemplate进行调用
消费者Feign:
需要依赖:
spring-cloud-starter-netflix-eureka-client
spring-cloud-starter-openfeign
需要注解:
@SpringCloudApplication
相当于
@SpringBootApplication
@EnableDiscoveryClient 注册与发现
@EnableCircuitBreaker 断路器
@EnableFeignClient
需要配置:
Eureka注册与发现
代码实现:
使用接口直接调用
@FeignClient("HELLO-SERVICE")
@Service
public interface HelloService {
@GetMapping("/hello")
String hello();
使用api中间层
1、中间层定义接口,如下


注册/发现/配置/Eureka/注解/依赖/Spring/Client/Enable/Discovery/ 注册/发现/配置/Eureka/注解/依赖/Spring/Client/Enable/Discovery/
-1 条回复
登录 后才能参与评论
-->