首页 > 其他 > 详细

应用通信-方案二:Feign

时间:2018-09-05 11:02:37      阅读:200      评论:0      收藏:0      [点我收藏+]
------------------客户端controller层---------------------
@RestController
public class ClientFeignController {

	@Autowired
	private ProductFeignInterface productFeignInterface;

	@GetMapping("/msg")
	public String msg() {
		String msg = productFeignInterface.getMsg();
		return msg;
	}
	
}


-----------------客户端feign调用的接口-----------------------
/**
 * name:被调用的服务名称
 */
@FeignClient(name = "product")
public interface ProductFeignInterface {

	/**
	 * 根据getMapping匹配接口,与方法名无关
	 * @return
	 */
	@GetMapping("/product/getMsg")
	public String getMsg();
}

------------------服务端接口-----------------------------------
@RestController
public class ServerController {

	@GetMapping("/product/getMsg")
	public String msg() {
		return "this is product‘ msg 1";
	}
}

  

应用通信-方案二:Feign

原文:https://www.cnblogs.com/yuefeng123/p/9590813.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!