Postman Code Java-Unirest 代码的依赖
本来是Postman的Code直接使用的,结果根据这个名字 Unirest,搜出来了很多依赖,使用了排名第一的,
https://search.maven.org/search?q=Unirest
结果发现Postman的Code
Unirest.setTimeouts(0, 0); 在我使用的依赖里根本没有这个的参数 再搜一下,就发现了,不是com.konghq unirest-java 4.0.0-RC2
而是
com.mashape.unirest unirest-java 1.4.9
fo了,
postman代码
Unirest.setTimeouts(0, 0); HttpResponseresponse = Unirest.get("urlxxxxx") .asString();
结果一运行,居然还报错了,JSONArray 和org.json not found之前的报错
原本项目里有使用
com.alibaba fastjson 1.2.58
没的办法,
只能exclude
com.alibaba fastjson 1.2.58 json org.json
然后再单独引入
org.json json 20220320
后来发现,Unriest还有关联的其它的基础依赖
好吧,继续
org.apache.httpcomponents httpclient org.apache.httpcomponents httpasyncclient org.apache.httpcomponents httpmime
完成!
请求第三方接口
import com.mashape.unirest.http.HttpResponse; import com.mashape.unirest.http.Unirest; import com.mashape.unirest.http.exceptions.UnirestException;
@PostMapping("/Xxxx")
public ResponseEntity