FeignConfig.java 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. package com.persagy.fm.common.client;
  2. import feign.Logger;
  3. import feign.codec.Encoder;
  4. import feign.form.spring.SpringFormEncoder;
  5. import org.springframework.beans.factory.ObjectFactory;
  6. import org.springframework.beans.factory.annotation.Autowired;
  7. import org.springframework.boot.autoconfigure.http.HttpMessageConverters;
  8. import org.springframework.cloud.openfeign.support.SpringEncoder;
  9. import org.springframework.context.annotation.Bean;
  10. import org.springframework.context.annotation.Configuration;
  11. import org.springframework.context.annotation.Primary;
  12. import org.springframework.context.annotation.Scope;
  13. import static org.springframework.beans.factory.config.BeanDefinition.SCOPE_PROTOTYPE;
  14. /**
  15. * feign配置类
  16. *
  17. * @author lixing
  18. * @version V1.0 2021/3/29 8:11 下午
  19. */
  20. @Configuration
  21. public class FeignConfig {
  22. @Autowired
  23. private ObjectFactory<HttpMessageConverters> messageConverters;
  24. @Bean
  25. @Primary
  26. @Scope(SCOPE_PROTOTYPE)
  27. Encoder feignFormEncoder() {
  28. return new SpringFormEncoder(new SpringEncoder(this.messageConverters));
  29. }
  30. @Bean
  31. Logger.Level feignLevel(){
  32. return Logger.Level.FULL;
  33. }
  34. }