SpringCloud学习中遇到的一些bug

2019-08-07  本文已影响0人  爱上游戏开发

bug

There was a problem with the instance info replicator

# 注册Eureka服务
eureka:
  client:
    # Eureka服务注册中心会将自己作为客户端来尝试注册它自己,必須禁止
    register-with-eureka: false
    fetch-registry: false

实体类转化出错: disable SerializationFeature.FAIL_ON_EMPTY_BEANS

@JsonIgnoreProperties(value = { "hibernateLazyInitializer", "handler" })

This application has no explicit mapping for /error, so you are seeing this as a fallback.

message:Request method 'POST' not supported

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方法进行发送请求。可能是我没找到相应的注解或使用方法错误。
    @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);
}

Error creating bean with name 'eurekaAutoServiceRegistration'

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!)

Read timed out

解决第一次请求报超时异常的方案

Cannot execute request on any known server

# 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

com.netflix.client.ClientException: Load balancer does not have available server for client: microservice-provider-user

  1. 确定本机是否关闭防火墙
  2. 是否导入eureka的jar包
    <!-- 注册Eureka服务 -->
    <dependency>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
    </dependency>
  1. 确定是否导入hystrix的jar包
    <!-- 配置hystrix所需依赖的包 -->
    <dependency>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-starter-netflix-hystrix</artifactId>
    </dependency>
  1. 确定配置文件服务前面是否有空格


Unable to connect to Command Metric Stream

hystrix.stream一直是ping

turbine.stream一直是ping

Health Indicator访问无结果

Turbine监控多个服务,配置后,出现只监控到一部分服务情况

"description":"No key was installed for encryption service","status":"NO_KEY"

{
    "description": "No key was installed for encryption service",
    "status": "NO_KEY"
}
encrypt: 
  key: foobar

如果是在application.yml中配置秘钥有可能读取不到,依然报该错误

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);
        }
    }
}
上一篇 下一篇

猜你喜欢

热点阅读