grails下的httpclient

httpclient已经发布到4.3版本了,其中的API发生了巨大的变化,尤其是对于关闭连接显得更加容易理解,比如引入了CloseableHttpResponse。

然而grails2.3.2中自带了httpclient4.2.5,而即便是这么小差别的httpclient版本号,4.3版本的API还是不兼容4.2.5。

在编写一个抓取脚本时,由于使用了httpclient4.3,一直会报告HttpClient INSTANCE属性找不到这样的错误,调查下来才发现是由于httpclient4.3中的那个类中有这个属性,而httpclient4.2那个类中没有INSTANCE属性,也就是说在运行脚本时,系统使用了grails中自带的httpclient版本,而没有使用我们新引入的4.3。

搜索了很多,大致的解决方式是修改BuildConfig.groovy:

grails.project.dependency.resolution = {// inherit Grails’ default dependenciesinherits(“global”) {// specify dependency exclusions here; for example, uncomment this to disable ehcache:// excludes ‘ehcache’excludes ‘httpclient’},希望你灰暗的心情在此刻明亮起来,去迎接美好的明天!

grails下的httpclient

相关文章:

你感兴趣的文章:

标签云: