openfeign : 使用另一种暴露方法暴露接口


OpenFeign是一个另类的注册

引入pom文件

    
        org.springframework.cloud
        spring-cloud-starter-openfeign
    

在注册端暴露接口
定义一个接口: controller一样

@FeignClient("client")
package com.example.demoopenribbon.config;

import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.RequestMapping;

@Component
@FeignClient("client")
public interface openribbontest {
    //向外暴露
    @RequestMapping("/UserSay")
    public String saySomeThing();
}


当有人访问期间借口方法时候就转去调用 controller的方法调用
控制方法
package com.example.demoopenribbon.controller;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class clientcontroller {

@RequestMapping("/UserSay")
public String saySomeThing(){
    return "我是注册一号 端口8088";
}
}


@FeignClient("client")为什么用client的名字