Maven项目 - OpenFeign使用细节 - 从此和httpClient说再见
程序员文章站
2022-07-02 13:00:02
maven项目使用openfeign,从此和httpClient说拜拜 pom.xml: io.github.openfeign feign-jaxb 9.7.0
maven项目使用openfeign,从此和httpclient说拜拜
pom.xml:
<dependency> <groupid>io.github.openfeign</groupid> <artifactid>feign-jaxb</artifactid> <version>9.7.0</version> </dependency> <dependency> <groupid>io.github.openfeign</groupid> <artifactid>feign-jackson</artifactid> <version>9.7.0</version> </dependency> <dependency> <groupid>io.github.openfeign</groupid> <artifactid>feign-core</artifactid> <version>9.7.0</version> </dependency>
响应头实体类:
/** * esb返回结果 * * @author shengyang.xiao */ public class esbrequest<request_data> { /** * 响应头 */ @jsonproperty("esbreqheader") private esbreqheader resheader; /** * 响应数据集 */ @jsonproperty("esbreqdata") private list<request_data> reqdata; public esbreqheader getresheader() { return resheader; } public void setresheader(esbreqheader resheader) { this.resheader = resheader; } public list<request_data> getreqdata() { return reqdata; } public void setreqdata(list<request_data> reqdata) { this.reqdata = reqdata; } }
client:
/** * esb服务客户端 * * @author shengyang.xiao * @since 2019-08-20 16:08 */ public interface esbclient { /** * 从sso获取当前系统的帐户信息 * * @param request * @return esbresponse<employeedto> * @author shengyang.xiao * @since 2019-08-20 16:08 */ @requestline("post ") @headers("content-type: application/json") esbresponse<employeedto> queryaccountbyrescodefromsso(esbrequest<queryaccountrequestdata> request); }