支持 feign 处理 content-type [text/plain] 返回内容
对比新文件 |
| | |
| | | package cn.lihu.jh.module.ecg.config; |
| | | |
| | | import org.springframework.http.MediaType; |
| | | import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | public class MyJackson2HttpMessageConverter extends MappingJackson2HttpMessageConverter { |
| | | public MyJackson2HttpMessageConverter() { |
| | | List<MediaType> mediaTypes = new ArrayList<>(); |
| | | mediaTypes.add(MediaType.TEXT_PLAIN); |
| | | mediaTypes.add(MediaType.TEXT_HTML); |
| | | setSupportedMediaTypes(mediaTypes); |
| | | } |
| | | } |
对比新文件 |
| | |
| | | package cn.lihu.jh.module.ecg.config; |
| | | |
| | | import org.springframework.context.annotation.Bean; |
| | | import org.springframework.context.annotation.Configuration; |
| | | |
| | | import feign.codec.Decoder; |
| | | import org.springframework.beans.factory.ObjectFactory; |
| | | import org.springframework.boot.autoconfigure.http.HttpMessageConverters; |
| | | import org.springframework.cloud.openfeign.support.SpringDecoder; |
| | | |
| | | |
| | | @Configuration |
| | | public class MyOpenFeignConfig { |
| | | |
| | | @Bean |
| | | public Decoder feignDecoder() { |
| | | MyJackson2HttpMessageConverter converter = new MyJackson2HttpMessageConverter(); |
| | | ObjectFactory<HttpMessageConverters> objectFactory = () -> new HttpMessageConverters(converter); |
| | | return new SpringDecoder(objectFactory); |
| | | } |
| | | } |
| | |
| | | |
| | | @FeignClient(name = "remote-data-service", url = "${openfeign.server}") |
| | | public interface RemoteDataService { |
| | | @PostMapping(value="/hai/HttpEntry/", produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE) |
| | | @PostMapping(value="/hai/HttpEntry/", produces = MediaType.APPLICATION_JSON_VALUE/*, consumes = MediaType.APPLICATION_JSON_VALUE*/) |
| | | public RestApiResult<AppointmentExternal> httpApi( @RequestParam("service") String service, |
| | | @RequestParam("urid") String urid, |
| | | @RequestParam("pwd") String pwd, |