[英]java.lang.NoClassDefFoundError org/apache/commons/logging/LogFactory at org.apache.http.conn.ssl
I'm trying to send http request POST to my goolge form to update my worksheet, but have this error in Android Studio: 我正在尝试将http请求POST发送到goolge表单以更新工作表,但是在Android Studio中出现此错误:
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/logging/LogFactory at org.apache.http.conn.ssl
线程“主”中的异常java.lang.NoClassDefFoundError:org.apache.http.conn.ssl上的org / apache / commons / logging / LogFactory
At this line: CloseableHttpClient httpClient = HttpClientBuilder.create().build();
在这一行:
CloseableHttpClient httpClient = HttpClientBuilder.create().build();
But in Eclipse it works!!! 但是在Eclipse中它可以工作!!!
My code is: 我的代码是:
public class MyClass{
public static void main(String[] args)
throws IOException, ServiceException
{
String fullUrl = "https://docs.google.com/forms/d/**key**/formResponse";
CloseableHttpClient httpClient = HttpClientBuilder.create().build();
HttpContext localContext = new BasicHttpContext();
HttpPost httpPost = new HttpPost(fullUrl);
httpPost.setHeader("Content-Type", "application/x-www-form-urlencoded");
HttpResponse response = null;
String data = "entry_770028073=" + URLEncoder.encode("ITPOD_pp1")+"&"+"entry_835458425=" + URLEncoder.encode("sr1");
StringEntity tmp = new StringEntity(data,"UTF-8");
httpPost.setEntity(tmp);
try {
response = httpClient.execute(httpPost,localContext);
if (response != null) {
String res = EntityUtils.toString(response.getEntity());
}
} catch (Exception e) {}
}
}
Please help me! 请帮我!
您缺少项目中的common-loggins
库 ,在Eclipse中,当您创建项目时它默认包含了
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.