# 注册Eureka服务
eureka:
client:
# Eureka服务注册中心会将自己作为客户端来尝试注册它自己,必須禁止
register-with-eureka: false
fetch-registry: false
@JsonIgnoreProperties(value = { "hibernateLazyInitializer", "handler" })
There was an unexpected error (type=Internal Server Error, status=500). status 405 reading UserFeignClient#getUser(User); content: {"timestamp":"2018-09-07T09:01:14.290+0000","status":405,"error":"Method Not Allowed","message":"Request method 'POST' not supported","path":"/feign-get-user"}
错误原因: 该请求不会成功,只要参数是复杂对象,即使指定了是GET方法,feign依然会以POST方法进行发送请求。可能是我没找到相应的注解或使用方法错误。
解决办法:
// 该请求不会成功,只要参数是复杂对象,即使指定了是GET方法,feign依然会以POST方法进行发送请求。可能是我没找到相应的注解或使用方法错误。
@RequestMapping(method = RequestMethod.GET, value = "/feign-get-user")
public User getUser(User user);
//正确用法
@RequestMapping(method = RequestMethod.GET, value = "/feign-get-user")
public User getUser(@RequestParam("id") Long id, @RequestParam("username") String username, @RequestParam("age") String age);
}
org.springframework.beans.factory.BeanCreationNotAllowedException: Error creating bean with name 'eurekaAutoServiceRegistration': Singleton bean creation not allowed while singletons of this factory are in destruction (Do not request a bean from a BeanFactory in a destroy method implementation!)
hystrix.command.default.execution.isolation.thread.timeoutInMilliseconds: 5000
hystrix.command.default.execution.timeout.enabled: false
feign.hystrix.enabled: false
# application.yml (Two Peer Aware Eureka Servers).
---
spring:
profiles: peer1
eureka:
instance:
hostname: peer1
client:
serviceUrl:
defaultZone: http://peer2/eureka/
---
spring:
profiles: peer2
eureka:
instance:
hostname: peer2
client:
serviceUrl:
defaultZone: http://peer1/eureka/
127.0.0.1 peer1 peer2 peer3
org.springframework.cloud
spring-cloud-starter-netflix-eureka-client
org.springframework.cloud spring-cloud-starter-netflix-hystrix
org.springframework.boot
spring-boot-starter-actuator
# 配置Hystrix Metrics Stream
management:
endpoints:
web:
exposure:
include: hystrix.stream
org.springframework.boot
spring-boot-starter-actuator
# 使用Hystrix Metrics Stream必备
management:
endpoints:
web:
exposure:
include: hystrix.stream
# 注册Eureka服务
eureka:
client:
register-with-eureka: false
fetch-registry: false
org.springframework.boot
spring-boot-starter-actuator
# 注册Eureka服务
eureka:
client:
# register-with-eureka: false
# fetch-registry: false
org.springframework.boot
spring-boot-starter-actuator
org.springframework.boot
spring-boot-starter-actuator
{
"_links": {
"self": {
"href": "http://localhost:8030/actuator",
"templated": false
},
"health": {
"href": "http://localhost:8030/actuator/health",
"templated": false
},
"info": {
"href": "http://localhost:8030/actuator/info",
"templated": false
}
}
}
# 0、配置多个监控服务
turbine:
appConfig: microservice-consumer-goods-feign-with-hystrix,microservice-consumer-goods-ribbon-with-hystrix
clusterNameExpression: "'default'"
# 1、仅配置监控一个服务
turbine:
aggregator:
clusterConfig: MICROSERVICE-CONSUMER-GOODS-RIBBON-WITH-HYSTRIX
appConfig: microservice-consumer-goods-ribbon-with-hystrix
//配置hystrix所需注解
@EnableCircuitBreaker