openFegin是声明试的调用组件  本事是ribbon封装实现的
 
  @RequestMapping("/all")
    public R queryAllBrand(){
        BrandEntity brandEntity = new BrandEntity();
        brandEntity.setName("华为");
        System.out.println(R.ok().put("brands",brandEntity));
        return R.ok().put("brands",brandEntity);
    }
 
  <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-openfeign</artifactId>
        </dependency>
 
然后创建fegin接口  因为是订单服务远程调用商品服务  那么需要在订单服务中创建
 

 
 
@FeignClient(name = "mall-product")/*这里写入你要远程调用的服务*/
public interface ProductService {
    /*这里需要将访问的接口地址补全  加上controller上面带的地址*/
    @RequestMapping("/mall_pms/brand/all")
    public R queryAllBrand();
}
然后我们在controller调用该接口 利用该接口去远程调用product服务
@RequestMapping("/products")
public R queryProduct(){
    /*openFegin远程调用服务*/
  return   R.ok().put("products",productService.queryAllBrand());
}
 
 
 
接下来需要在启动类上开启远程服务调用  也是在发起远程服务调用方添加  也就是order服务启动类上添加
 
@SpringBootApplication
/*指定接口fegin接口路径*/
@EnableFeignClients(basePackages = "com.msb.mall.order.fegin")
public class MallOrderApplication {
    
    public static void main(String[] args) {
        SpringApplication.run(MallOrderApplication.class, args);
    }
    
}