本文主要是介绍脱离SpringCloud,怎么使用Feign远程调用接口?Gradle项目教程,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
一、引入依赖
implementation 'io.github.openfeign:feign-core:11.0'
implementation 'com.netflix.feign:feign-jackson:8.18.0'
二、客户端接口类 MyFeignClient
package com.fdw.study.feign;import com.fdw.study.validate.User;
import feign.RequestLine;
import org.springframework.web.bind.annotation.RequestBody;/*** @program: hibbernatestudy* @description: 脱离springCloud使用Feign* @author:* @create: 2023-12-22 15:43**/
public interface MyFeignClient {@RequestLine("POST /feign-test")User getUserByfeign(@RequestBody String id);
}
三、客户端调用服务类
FeignService:
package com.fdw.study.feign;import com.fdw.study.validate.User;public interface FeignService {public User getUser(String id);
}
FeignServiceImpl:
package com.fdw.study.feign;imp
这篇关于脱离SpringCloud,怎么使用Feign远程调用接口?Gradle项目教程的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!