Spring-Cloud微服务踩坑

@feignclient和@requestmapping混用的时候出错

重写springmvc扫描controller时不带有@feignclient才实例化

@Configuration
@ConditionalOnClass({Feign.class})
public class FeignConfiguration {
    @Bean
    public WebMvcRegistrations feignWebRegistrations() {
        return new WebMvcRegistrationsAdapter() {
            @Override
            public RequestMappingHandlerMapping getRequestMappingHandlerMapping() {
                return new FeignRequestMappingHandlerMapping();
            }
        };
    }

    private static class FeignRequestMappingHandlerMapping extends RequestMappingHandlerMapping {
        @Override
        protected boolean isHandler(Class beanType) {
            return super.isHandler(beanType) &&
                    !AnnotatedElementUtils.hasAnnotation(beanType, FeignClient.class);
        }
    }
}

SpringCloud使用Zuul出现“Forwarding error”错误解决方法

在application.yml中添加ribbon的超时时间设置:

ribbon:  
  ReadTimeout: 3000
  ConnectTimeout: 3000
zuul:
    host:
        connect-timeout-millis: 3000
        socket-timeout-millis: 3000
hystrix:
    command:
        default:
            execution:
                isolation:
                    thread:
                        timeout-in-milliseconds: 3000

你可能感兴趣的:(Spring-Cloud微服务踩坑)