我有一个使用Spring注解的服务定义。例如(源代码):
@RequestMapping(value = "/ex/foos/{id}", method = GET)
@ResponseBody
public String getFoosBySimplePathWithPathVariable(
@PathVariable("id") long id) {
return "Get a specific Foo with id=" + id;
}
问题在于Spring(或其他库)是否可以自动创建远程API的实现(客户端),而无需手动输入路径、方法类型、参数名称等(例如使用RestTemplate时需要)。以下是这样一个客户端的使用示例:
FooClient fooClient = new FooClient("http://localhost:8080");
String foo = fooClient.getFoosBySimplePathWithPathVariable(3l);
我该如何获取这样一个“生成”的客户端实现?