项目不需要微服务/又不愿勇dubbo ,自己写RestTemplete维护麻烦。可以独立使用Openfeign做远程调用 配合SpringSecurity 做权限接口安全处理;
rpc-server示例
@RequestMapping("testurl")
public String test(@RequestParam("uname") String uname, HttpServletRequest request ){
System.out.println("header:"+request.getHeader("xxx"));
return "data"+uname;
}
@PostMapping("saveuser")
public String saveUser(@RequestBody UserInfo user, HttpServletRequest request){
System.out.println(user);
System.out.println("header:"+request.getHeader("xxx"));
return "ok:"+ user.getName();
}
rpc-feign-client调用端
TestService
@FeignClient(value = "rpcserver-service",
url = "localhost:8666",
path = "/")
public interface TestService {
@GetMapping(value