feign 序列化_Spring Feign 序列化机制

Spring Cloud封装Feign,直接使用Spring MVC注解以及HttpMessageConverters来序列化。

Spring Boot有autoconfigure机制,当spring boot中引入了spring-web jar包的时候,HttpMessageConvertersAutoConfiguration便会起作用,另外当引入了ObjectMapper类时候,MappingJackson2HttpMessageConverterConfiguration便会起作用,从而自动加入了HttpMessageConverters中,这样feign就会直接来序列化json了。

FooConfiguration does not need to be annotated with @Configuration. However, if it is, then take care to exclude it from any @ComponentScan that would otherwise include this configuration as it will become the default source for feign.Decoder, feign.Encoder, feign.Contract, etc., when specified. This can be avoided by putting it in a separate, non-overlapping package from any @ComponentScan or @SpringBootApplication, or it can be explicitly excluded in @ComponentScan.

大致意思是,FeignClient注解上可以指定configuration属性,但是对于指定的configuration属性的类不需要使用@Configuration注解,不然这个里面设置的属性将会覆盖默认的配置属性,转而使用该configuration配置的。如果不使用@Configuration注解,那么只有该FeignClient会使用该configuration。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值