springcloud使用feign实现服务间条用,参数数据太大,无法调用成功解决方法
2018-07-24 17:46
4427 查看
公司项目做一个关于程序报错,实现给管理发送邮件提醒时使用springcloud的feign调用接口时总是走断路器
经过分析得出,调用接口时传递的参数过大,无法调用成功,解决方法如下:
1:引入springcloud关于feign依赖
2:编写配置项
3:启动类上添加注解
4:接口调用使用注解
经过分析得出,调用接口时传递的参数过大,无法调用成功,解决方法如下:
1:引入springcloud关于feign依赖
<dependency> <groupId>io.github.openfeign.form</groupId> <artifactId>feign-form</artifactId> <version>3.0.3</version> </dependency> <dependency> <groupId>io.github.openfeign.form</groupId> <artifactId>feign-form-spring</artifactId> <version>3.0.3</version> </dependency>
2:编写配置项
@Configuration public class CoreFeignConfiguration { @Autowired private ObjectFactory<HttpMessageConverters> messageConverters; @Bean @Primary @Scope(SCOPE_PROTOTYPE) Encoder feignFormEncoder() { return new SpringFormEncoder(new SpringEncoder(this.messageConverters)); } @Bean public Logger.Level logger() { return Logger.Level.FULL; } }
3:启动类上添加注解
@EnableTransactionManagement
4:接口调用使用注解
@FeignClient(value = "sendemail", fallback = SendEmailHystrix.class, configuration = CoreFeignConfiguration.class) public interface SendEmail { @RequestMapping(method = RequestMethod.POST, value = "sendemail/commonMail" ,consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE) Object sendEmail(@RequestParam("addTo") String addTo, @RequestParam("setSubject") String setSubject, @PathVariable("details") String details); }
相关文章推荐
- 使用Spring cloud Feign在后台服务之间调用传递Multipart无法传递的问题
- 使用Spring Cloud Feign作为HTTP客户端调用远程HTTP服务的方法(推荐)
- spring cloud feign实现远程调用服务传输文件的方法
- 使用Spring Cloud Feign作为HTTP客户端调用远程HTTP服务
- 使用Spring Cloud Feign作为HTTP客户端调用远程HTTP服务
- 使用Spring Cloud Feign作为HTTP客户端调用远程HTTP服务
- spring cloud使用Feign实现远程接口的调用
- 使用Spring Cloud Feign作为HTTP客户端调用远程HTTP服务
- 微服务框架Spring Cloud介绍 Part4: 使用Eureka, Ribbon, Feign实现REST服务客户端
- 使用Spring Cloud Feign作为HTTP客户端调用远程HTTP服务
- 使用Spring Cloud Feign作为HTTP客户端调用远程HTTP服务
- SpringCloud 查找调用REST服务使用RestTemplate(ribbon负载)或feign模式 教程源码 火推
- SpringCloud使用Feign进行服务调用
- spring cloud feign 调用微服务转发不了request请求头和参数问题解决方案
- Spring Cloud(十一)声名式服务调用:Feign的使用 (上)
- Spring Boot使用Feign客户端调用远程服务时出现:timed-out and no fallback available,failed and no fallback available的问题解决
- Spring Cloud版——电影售票系统<三>使用Feign实现声明式REST调用
- spring cloud之服务调用及使用ribbon实现负载均衡(三)
- 使用Spring Cloud Feign作为HTTP客户端调用远程HTTP服务
- spring cloud 使用Hystrix 实现断路器进行服务容错保护的方法