欢迎来到尧图网

客户服务 关于我们

您的位置:首页 > 健康 > 美食 > Forest-HTTP客户端框架学习笔记

Forest-HTTP客户端框架学习笔记

2025/4/19 10:14:53 来源:https://blog.csdn.net/qq_45773425/article/details/143686680  浏览:    关键词:Forest-HTTP客户端框架学习笔记
        <!--引入依赖--><dependency><groupId>com.dtflys.forest</groupId><artifactId>forest-spring-boot-starter</artifactId><version>1.5.36</version></dependency>

applicant.yam加入以下配置

forest:max-connections: 1000        # 连接池最大连接数connect-timeout: 3000        # 连接超时时间,单位为毫秒read-timeout: 3000           # 数据读取超时时间,单位为毫秒

在启动类Application指定路径

@ForestScan(basePackages = "com.example.thymeleaf.client")

创建Client接口

package com.example.thymeleaf.client;import com.dtflys.forest.annotation.Body;
import com.dtflys.forest.annotation.Post;public interface MyClient {/*** 配置拦截器测试** @param username* @return*/@Post(url = "http://some/path",contentType = "application/x-www-form-urlencoded")String testInterceptor(@Body("APPID") String value1,  @Body("imaMag") String value2);}

Controller层
 

    //引入MyClient @ResourceMyClient myClient;@RequestMapping("/testClient")public String testClient() {String location = myClient.testInterceptor("APP","FGDGHDGAUFEHANFNA");System.out.println(location);return location;}

推荐一篇文章:轻量级HTTP客户端框架—Forest学习笔记_forest框架-CSDN博客

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com

热搜词