源码地址
Feign配置
#Hystrix支持,如果为true,hystrix库必须在classpath中
feign.hystrix.enabled=false
#请求和响应GZIP压缩支持
feign.compression.request.enabled=true
feign.compression.response.enabled=true
#支持压缩的mime types
feign.compression.request.enabled=true
feign.compression.request.mime-types=text/xml,application/xml,application/json
feign.compression.request.min-request-size=2048
# 日志支持
logging.level.project.user.UserClient: DEBUG
自定义配置
自定义配置类不能定义在启动类和Composcan扫描到的类中,要不会被重复初始化,引起冲突
-
- 定义自定义配置类
package com.wy2.cloud.microservice.user.configuration;
import feign.Contract;
import feign.Logger;
import org.springframework.context.annotation.Bean;
/**
* 系统名称 xx平台
* 工程名称 wy2-cloud
* 创建时间 2017/9/13 11:46
*
* @author admin
* @since 1.8
*/
public class FeignClientConfiguration {
/* @Bean
public Contract feignContract(){
Contract.Default contract = new Contract.Default();
return contract;
}*/
@Bean
Logger.Level feignLoggerLevel(){
return Logger.Level.FULL;
}
}
- 2.配置FeignClient日志级别(消费服务的接口所在包,必须是debug)
logging:
level:
com:
wy2:
cloud:
microservice:
user:
service: debug
- 3.消费接口注解中增加配置
@FeignClient(name=”${self.userServiceId}”,fallback = UserServiceHystrix.class,configuration ={FeignClientConfiguration.class})
package com.wy2.cloud.microservice.user.service;
import com.wy2.cloud.microservice.pojo.user.UserLoginInput;