Openfix : 使用另一种暴露方法暴露接口
作者:互联网
OpenFeign是一个另类的注册
引入pom文件
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-openfeign</artifactId>
</dependency>
在注册端暴露接口
定义一个接口: 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的名字
标签:FeignClient,RequestMapping,暴露,springframework,接口,Openfix,import,org,public 来源: https://www.cnblogs.com/SweetheartAndPeaches/p/15568134.html