Eureka 服务注册

Ribbon 客户端负载均衡

Feign 远程请求接口化

  • @GetMapping不支持
  • @PathVarlable必须设置value
  • 传递复杂对象强制使用的POST传递 若接收端必须是Get 则传递时方法里需要对复杂对象进行解析成单个参数

启动程序后首次调用超时问题

解决方案

  • 1.增加hystrix超时时间
    hystrix.command.default.execution.isolation.thread.timeoutInMilliseconds: 5000
  • 2 关闭超时检测
    hystrix.command.default.execution.timeout.enabled: false
  • 3 禁用feign的hystrix
    feign.hystrix.enabled: false

    其他

    启动java 设置内存

    java -Xms64m -Xmx128m -jar microservice-provider-user-0.0.1-SNAPSHOT.jar

启动java 设置不同的profile组

java -jar microservice-provider-user-0.0.1-SNAPSHOT.jar –spring.profiles.active=a8000


spring:
application:
name: microservice-provider-user
---
spring:
profiles: a8000
server:
port: 8000


---
spring:
profiles: a8001
server:
port: 8001


---
spring:
profiles: a8002
server:
port: 8002

spring cloud使用consul注册发现

<dependency>  
<groupId>org.springframework.cloud<&#47;groupId> 
<artifactId>spring-cloud-starter-consul-discovery<&#47;artifactId>
<&#47;dependency>

若注册状态提示204

<dependency> 
<groupId>org.springframework.boot<&#47;groupId> 
<artifactId>spring-boot-starter-web<&#47;artifactId>
<&#47;dependency>

主类添加

@EnableDiscoveryClient