在当用@PathVariable传路径变量时,服务总报500.
百度发现 @PathVariable时,@RequestMapping不能用GetMapping直接替换,必须用对其value参数直接赋值才可用。正确如下:
@FeignClient(value = "test")
public interface IFeignTestService {
// if PathVariable is used, it is forbidden to use @GetMapping to replace @RequestMapping;
@RequestMapping(value = "/test/ribbon/test/{id}", method = RequestMethod.GET)
public Object getTest(@PathVariable("id") String id);
}
当用@ComponentScan 显示加载指定包,排除FeignConguration。
对@FeignClient的想要使用指定自定义配置的,可用conguration属性来指定
日志级别枚举类Logger.Level
NONE:不输出日志
BASIC:输出请求方法、URL、响应状态码、执行时间
HEADERS:基本信息以及请求和响应头
FULL:请求和响应的heads、body、metadata,建议使用这个级别
注:1. Feign的Level日志级别配置默认是:NONE,不要跟log日志混淆。
2. feign 日志的 log日志级别为DEBUG.
/**
if this configuration is scanned by the @ComponentScan, it will take effects on all the FeignClients.
Therefore, we use IgnoreComponentScan to avoid this configuration’s being scanned so that it can work
the specific Feign clients with annotation @FeignClient taking FeignConfiguration.class as the value of
its attribute configuration.
*/
@Configuration
@IgnoreComponentScan
public class FeignConfiguration {
/**
}
参: Spring Cloud中Feign常见问题