# 註冊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);
}
}
}
複製代碼