二言目 - Open Feign
type: channel
link: https://blog.piemoe.com/tag/Open-Feign/
items: openFeign远程调用

openFeign远程调用
type: item
date: 2019-04-22T12:45:00+08:00
description: 1.服务生产方生产方方法示例@RequestMapping("/member/list") public R memberCoupon(){ CouponEntity couponEntity = new CouponEntity(); couponEntity.setCouponName("满一百减十"); return R.ok().put("coupons", Collections.singletonList(couponEntity)); }2.服务消费方2.1引入openfeign2.1.1 springbootApplication.java开启远程调用@SpringBootApplication @EnableDiscoveryClient @EnableFeignClients public class GulimallMemberApplication { public static void main(String[] args) { SpringApplication.run(GulimallMemberApplication.class, args); } }2.1.2 创建接口编写一个接口，告诉 springcloud 这个接口需要远程服务@FeignClient("gulimall-coupon") 其中，gulimall-coupon 为被调用的服务名——spring.applicaiton.name@FeignClient("gulimall-coupon") //调用的服务名 public interface CouponFeignService { @RequestMapping("/coupon/coupon/member/list") public R memberCoupon(); }3.结果http://localhost:8000/member/member/coupons