SpringCloud-微服务-服务之间的调用

本文探讨了在SpringCloud中实现服务间调用的三种方式:1) 使用Feign进行优雅的调用;2) 使用RestTemplate处理文件传输的复杂性;3) 通过OKHttp进行高效请求。特别提到了文件服务的OKHttp实现,并提供了GitHub上的代码资源链接以供参考。
摘要由CSDN通过智能技术生成

1.使用Feign

调用方:

import com.nick.movie.config.MultipartSupportConfig;
import com.nick.movie.utils.ResponseResult;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RequestPart;
import org.springframework.web.multipart.MultipartFile;

/**
 * @version V1.0
 * @ClassName:MovieService
 * @author: hbj
 * @CreateDate:2018/8/27 19:34
 */
@FeignClient(value = "file-server", path = "/attachment/file" ,configuration = MultipartSupportConfig.class)
public interface MicroCloudService {
    @RequestMapping(value = "/upload/single", produces = {MediaType.APPLICATION_JSON_UTF8_V
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值