1. 引入相关依赖
<dependency><groupId>cn.zhxu</groupId><artifactId>okhttps</artifactId><version>4.1.0</version>
</dependency>
2. 调用get请求
public List<CompanyVO> getCompanyList(CompanyVO vo) throws Exception {String reqUrl = "http://10.10.5.12:8090/api/relation/list";if (StrUtil.isNotBlank(vo.getName())){reqUrl = reqUrl + "?name=" + vo.getName();}HttpResult rst = OkHttps.sync(reqUrl).addHeader("Content-Type", "application/json").get();RfHttpResut rfHttpResut = JSONObject.parseObject(rst.getBody().toString(), RfHttpResut.class);if (!rfHttpResut.getCode().equals("200")) {throw new Exception("请求失败,返回码: " + rfHttpResut.getCode());}List<CompanyVO> dataList = (List<CompanyVO>) rfHttpResut.getData();return dataList;}
官方文档:起步 | OkHttps