應用通信-方案二:Feign
阿新 • • 發佈:2018-09-05
msg pri ctf feign public () inter turn return
------------------客戶端controller層--------------------- @RestController public class ClientFeignController { @Autowired private ProductFeignInterface productFeignInterface; @GetMapping("/msg") public String msg() { String msg = productFeignInterface.getMsg(); return msg; } } -----------------客戶端feign調用的接口----------------------- /** * name:被調用的服務名稱*/ @FeignClient(name = "product") public interface ProductFeignInterface { /** * 根據getMapping匹配接口,與方法名無關 * @return */ @GetMapping("/product/getMsg") public String getMsg(); } ------------------服務端接口----------------------------------- @RestController public class ServerController { @GetMapping("/product/getMsg") public String msg() { return "this is product‘ msg 1"; } }
應用通信-方案二:Feign