场景:
项目中使用apache http fluent发送http请求,写了一个自己的ResponseHandler来处理返回请求
public class HfiResponseHandler extends AbstractResponseHandler<String>
结果编译时报错Error:java:无法访问org.apache.http.annotation.Immutable 找不到org.apache.http.annotation.Immutable的类文件
查看AbstractResponseHandler
@Immutable
public abstract class AbstractResponseHandler<T> implements ResponseHandler<T> {
使用了@Immutable注解
原因:
参考:
cannot access org.apache.http.annotation.Immutable
升级log4j到log4j2报错:cannot access org.apache.http.annotation.NotThreadSafe
可以看出原因就是httpclient与httpcore的包不兼容
解决方案:
解决方案是:将httpcore的版本改成4.4.4(低于4.4.5即可)
项目中引入了
compile group: 'org.apache.httpcomponents', name: 'fluent-hc', version:'4.3.1'
httpcore版本是4.4.5
于是加入了依赖
compile group: 'org.apache.httpcomponents', name: 'httpcore', version: '4.4.4'
问题解决