尝试在Java中对我的API进行发布请求时遇到一些麻烦

时间:2019-05-14 06:53:36

标签: java rest http netbeans http-post

我正在使用Post将文件上传到我的API,该API已经完成,并且客户端也可以很好地上传,但是我收到此错误报告:

Exception in thread "Thread-0" java.lang.ClassCastException: class org.apache.http.impl.execchain.HttpResponseProxy cannot be cast to class java.net.http.HttpResponse (org.apache.http.impl.execchain.HttpResponseProxy is in unnamed module of loader 'app'; java.net.http.HttpResponse is in module java.net.http of loader 'platform')

他指定了我在代码中此行的位置:

HttpResponse response = (HttpResponse) HttpClients.createDefault().execute(post);

我从未使用过HttpResponse或其他java.net.http导入,因此,如果您对此有任何了解,我也非常感谢!

0 个答案:

没有答案