spring|spring cloud搭建过程中遇到的问题

1.zuul启动之后,每次第一次调用接口总是会出现下图所示错误,

spring|spring cloud搭建过程中遇到的问题
文章图片


网上搜索后,提示增加
hystrix:
command:
default:
execution:
timeout:
enabled: true
isolation:
thread:
timeoutInMilliseconds: 60000
ribbon:
ReadTimeout: 60000
ConnectTimeout: 60000
zuul: max: host: connections: 500 host: socket-timeout-millis: 60000 connect-timeout-millis: 60000
配置,增加后解决。原文地址:http://www.cnblogs.com/dauber/p/9424505.html
报错原因解释:
该配置中也包括了集群中单个实例报错,控制zuul调用其它实例的方法(尝试重新调用集群中服务器的数量,和超时后对本实例的再次重试次数)
同时在fegin的调用端也要用对应的ribbon和hystrix的配置,用来覆盖其默然配置的三秒超时时间,因为每次服务器重新启动之后,初次访问实例初始话的过程中比较耗时,所以在初次访问的时候超时的概率很大,
所以需要加上次配置抵消容器初始话后首次调用的超时现象。
【spring|spring cloud搭建过程中遇到的问题】对于首次调用超时的情况,还可以设置对应的feign.hystrix.enabled=false,默认去关闭hystrix的功能也是可以的,但是不推荐,尤其是生产环境
2.搭建完oauth2 授权服务,资源服务之后,登录,用户名密码正确,依然报 “坏的凭证”,
网上搜索后,提示在WebSecurityConfig中增加如下代码解决
@Bean // share AuthenticationManager for web and oauth
@Override
public AuthenticationManager authenticationManagerBean() throws Exception {
return super.authenticationManagerBean();
}
3.登录之后,拿获取到的token去请求其他接口时,报
{
"timestamp": 1544166144327,
"status": 403,
"error": "Forbidden",
"exception": "org.springframework.security.authentication.InsufficientAuthenticationException",
"message": "Access Denied",
"path": "/oauth/authorize"
}
转载于:https://my.oschina.net/ye39zi/blog/3016133

    推荐阅读