# 注册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"}html
错误缘由: 该请求不会成功,只要参数是复杂对象,即便指定了是GET方法,feign依然会以POST方法进行发送请求。多是我没找到相应的注解或使用方法错误。java
解决办法:git
// 该请求不会成功,只要参数是复杂对象,即便指定了是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!)github
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
复制代码
<!-- 注册Eureka服务 -->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
</dependency>
复制代码
<!-- 配置hystrix所需依赖的包 -->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-hystrix</artifactId>
</dependency>
复制代码
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
复制代码
# 配置Hystrix Metrics Stream
management:
endpoints:
web:
exposure:
include: hystrix.stream
复制代码
<!-- Actuator是SpringBoot提供的对应用系统的自省和监控的集成功能,能够查看应用配置的详细信息;
若是提示 Unable to connect to Command Metric Stream.则须要引入如下包!
-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
复制代码
# 使用Hystrix Metrics Stream必备
management:
endpoints:
web:
exposure:
include: hystrix.stream
复制代码
# 注册Eureka服务
eureka:
client:
register-with-eureka: false
fetch-registry: false
复制代码
<!-- Actuator是SpringBoot提供的对应用系统的自省和监控的集成功能,能够查看应用配置的详细信息;
若是提示 Unable to connect to Command Metric Stream.则须要引入如下包!
-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
复制代码
# 注册Eureka服务
eureka:
client:
# register-with-eureka: false
# fetch-registry: false
复制代码
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
复制代码
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
复制代码
{
"_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'"
复制代码
# 一、仅配置监控一个服务
turbine:
aggregator:
clusterConfig: MICROSERVICE-CONSUMER-GOODS-RIBBON-WITH-HYSTRIX
appConfig: microservice-consumer-goods-ribbon-with-hystrix
复制代码
//配置hystrix所需注解
@EnableCircuitBreaker
复制代码
{
"description": "No key was installed for encryption service",
"status": "NO_KEY"
}
复制代码
错误缘由:web
解决办法:算法
local_policy.jar
和US_export_policy.jar
%JDK_HOME%\jre\lib\security
目录下的这两个jar。bootstrap.yml
文件中配置秘钥:encrypt:
key: foobar
复制代码
若是是在application.yml
中配置秘钥有可能读取不到,依然报该错误spring
import java.security.*;
public class JceInfo {
public static void main(String[] args) {
System.out.println("-------列出加密服务提供者-----");
Provider[] pro = Security.getProviders();
for (Provider p : pro) {
System.out.println("Provider:" + p.getName() + " - version:" + p.getVersion());
System.out.println(p.getInfo());
}
System.out.println();
System.out.println("-------列出系统支持的 消息摘要算法:");
for (String s : Security.getAlgorithms("MessageDigest")) {
System.out.println(s);
}
System.out.println();
System.out.println("-------列出系统支持的生成 公钥和 私钥对的算法:");
for (String s : Security.getAlgorithms("KeyPairGenerator")) {
System.out.println(s);
}
}
}
复制代码