Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/318.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 如何将org.apache.http.legacy添加到sbt中_Java_Sbt_Apache Commons Httpclient - Fatal编程技术网

Java 如何将org.apache.http.legacy添加到sbt中

Java 如何将org.apache.http.legacy添加到sbt中,java,sbt,apache-commons-httpclient,Java,Sbt,Apache Commons Httpclient,我正在使用apache httpclient,但它找不到 import org.apache.http.impl.client.HttpClients; 在google上快速搜索,我找到了org.apache.http.legacy,但我找不到org.apache.http.legacy的组、工件和修订版 它们是什么?如何将依赖项添加到build.sbt文件中?stacktrace的总数为 [error] /Users/vangapellisanthosh/Development/coupon

我正在使用apache httpclient,但它找不到

import org.apache.http.impl.client.HttpClients;
在google上快速搜索,我找到了org.apache.http.legacy,但我找不到org.apache.http.legacy的组、工件和修订版

它们是什么?如何将依赖项添加到build.sbt文件中?stacktrace的总数为

[error] /Users/vangapellisanthosh/Development/coupon-engine-play/app/utils/LocalUtils.java:13: cannot find symbol
[error]   symbol:   class HttpClients
[error]   location: package org.apache.http.impl.client
[error] import org.apache.http.impl.client.HttpClients;
[error] /Users/vangapellisanthosh/Development/coupon-engine-play/app/utils/LocalUtils.java:66: cannot find symbol
[error]   symbol:   variable HttpClients
[error]   location: class utils.LocalUtils
[error]         HttpClient httpclient = HttpClients.createDefault();
[info] /Users/vangapellisanthosh/Development/coupon-engine-play/app/controllers/CouponsController.java: /Users/vangapellisanthosh/Development/coupon-engine-play/app/controllers/CouponsController.java uses or overrides a deprecated API.
[info] /Users/vangapellisanthosh/Development/coupon-engine-play/app/controllers/CouponsController.java: Recompile with -Xlint:deprecation for details.
[error] (compile:compileIncremental) javac returned nonzero exit code
[info] Compiling 6 Scala sources and 18 Java sources to /Users/vangapellisanthosh/Development/coupon-engine-play/target/scala-2.11/classes...
[error] /Users/vangapellisanthosh/Development/coupon-engine-play/app/utils/LocalUtils.java:13: cannot find symbol
[error]   symbol:   class HttpClients
[error]   location: package org.apache.http.impl.client
[error] import org.apache.http.impl.client.HttpClients;
[error] /Users/vangapellisanthosh/Development/coupon-engine-play/app/utils/LocalUtils.java:66: cannot find symbol
[error]   symbol:   variable HttpClients
[error]   location: class utils.LocalUtils
[error]         HttpClient httpclient = HttpClients.createDefault();
[info] /Users/vangapellisanthosh/Development/coupon-engine-play/app/controllers/CouponsController.java: /Users/vangapellisanthosh/Development/coupon-engine-play/app/controllers/CouponsController.java uses or overrides a deprecated API.
[info] /Users/vangapellisanthosh/Development/coupon-engine-play/app/controllers/CouponsController.java: Recompile with -Xlint:deprecation for details.
[error] (compile:compileIncremental) javac returned nonzero exit code
[error] application - 
我的代码是

HttpClient httpclient = HttpClients.createDefault();
HttpPost httppost = new HttpPost(URL);
httppost.addHeader(API_KEY, X_API_KEY);
// Request parameters and other properties.
List<NameValuePair> params = new ArrayList<NameValuePair>(2);
params.add(new BasicNameValuePair(GRANT_TYPE, "password"));
params.add(new BasicNameValuePair(USERNAME, _USERNAME));
params.add(new BasicNameValuePair(PASSWORD, O_PASSWORD));
httppost.setEntity(new UrlEncodedFormEntity(params, "UTF-8"));

HttpResponse response = httpclient.execute(httppost);
HttpEntity entity = response.getEntity();

if (entity != null) {
    InputStream instream = entity.getContent();
    try {
        System.out.println(instream);
    } finally {
        instream.close();
    }
}
HttpClient-HttpClient=HttpClients.createDefault();
HttpPost HttpPost=新的HttpPost(URL);
addHeader(API_键、X_API_键);
//请求参数和其他属性。
列表参数=新的ArrayList(2);
添加参数(新的BasicNameValuePair(授权类型,“密码”);
添加(新的BasicNameValuePair(用户名,_用户名));
添加(新的BasicNameValuePair(密码,O_密码));
setEntity(新的UrlEncodedFormEntity(参数,“UTF-8”);
HttpResponse response=httpclient.execute(httppost);
HttpEntity=response.getEntity();
如果(实体!=null){
InputStream instream=entity.getContent();
试一试{
系统输出打印LN(流内);
}最后{
流内关闭();
}
}
在google上快速搜索可以让我找到org.apache.http.legacy

不知道你搜索了什么,但我知道这是Android项目使用的依赖项

你要找的东西可以在

在google上快速搜索可以让我找到org.apache.http.legacy

不知道你搜索了什么,但我知道这是Android项目使用的依赖项

你要找的东西可以在

libraryDependencies += "org.apache.httpcomponents" % "httpclient" % "4.5.2"