1:Feign PathVariable annotation was empty on param 0.

 

  使用Feign的时候,在service中如果参数中带有

@PathVariable,@RequestParam形式的参数,则要用value=""标明对应的参数,否则会抛出IllegalStateException异常,
其中value的值应该和后面的参数名一样,否则会出现这样的异常:

2:配置 启动 Hystrix Dashboard 报错

项目中包好eureka-server,user-service,hystrix-service,hystrix-dashboard.

除了在hystrix-dashboard中添加


org.springframework.boot:spring-boot-starter-actuator


还要在hystrix-service里添加。

并且在hystrix-service中启动类中添加:


@Bean
public ServletRegistrationBean getServlet(){
    HystrixMetricsStreamServlet streamServlet = new HystrixMetricsStreamServlet();
    ServletRegistrationBean registrationBean = new ServletRegistrationBean(streamServlet);
    registrationBean.setLoadOnStartup(1);
    registrationBean.addUrlMappings("/actuator/hystrix.stream");
    registrationBean.setName("HystrixMetricsStreamServlet");
    return registrationBean;
}


这样就可以了。还有需要在hystrix-service的配置文件中添加:


#暴露hystrix监控端点
management.endpoints.web.exposure.include=*


3:spring Cloud config下的client服务中的配置文件不能像其他一样用application.properties文件,名称要改为bootstrap.properties.(由于之前都是用application的较多,容易出现错误。)

4:在springCloud的gateway网关的开发中遇到这样的异常:

Parameter 0 of method modifyRequestBodyGatewayFilterFactory in org.springframework.cloud.gateway.config.GatewayAutoConfiguration required a bean of type 'org.springframework.http.codec.ServerCodecConfigurer' that could not be found.

 

因为spring cloud gateway是基于webflux的,如果非要web支持的话需要导入spring-boot-starter-webflux而不是spring-boot-start-web。所以需要改成如下:

dependencies {
   // compile('org.springframework.cloud:spring-cloud-starter-gateway')
    implementation("org.springframework.cloud:spring-cloud-starter-gateway") {
        exclude group: 'org.springframework.boot', module: 'spring-boot-starter-web'
    }

}

这样启动就正常了。