HTTP API deprected warnings UTF_8, Scheme, ThreadS

2019-04-30 19:50发布

I'm new java. I created a java project to call my webservice(Servlet,Tomcat6.0).
To use http i had added the following jar files
1. httpclient-4.2.1
2. httpcore-4.2.1

For methods(In Bold) below i'm getting type deprecated warnings and not able to run the project.

HTTP.**UTF_8**
aSchemeRegistryL.register(new **Scheme**("http", PlainSocketFactory.getSocketFactory(), 80));
ClientConnectionManager ccm = new **ThreadSafeClientConnManager**(aHttpParamsL, aSchemeRegistryL);    

Help me to rectify it.

标签: java http
3条回答
smile是对你的礼貌
2楼-- · 2019-04-30 20:33

ThreadSafeClientConnManager class is deprecated, use PoolingClientConnectionManager and the constructor for Scheme you are using is deprecated too, use the other constructor found in that class.

As for the deprecated warnings, check that in Eclipse (I'm assuming you're using Eclipse, otherwise check for similar options in your IDE) that under Preferences->Java->Compiler->Errors/Warnings you don't have "Deprecated API" set to "Error" status.

查看更多
男人必须洒脱
3楼-- · 2019-04-30 20:52

Most of the time - check your java docs - they'll suggest an alternative class. See: ThreadSafeClientManager

And it will suggest instead of ThreadSafeClientManager use: PoolingClientConnectionManager

PoolingClientConnectionManager

As for the Scheme class, if you look at the javadocs, the class itself isn't deprecated, but the constructor you are using is: Scheme

查看更多
时光不老,我们不散
4楼-- · 2019-04-30 20:54

For HTTP.UTF_8 the alternative is Consts.UTF_8. It's weird they don't mention that in the docs...

查看更多
登录 后发表回答