How to import groovyx.net.http

隐身守侯 提交于 2019-11-27 17:43:10

问题


I don't understand maven or grape, and I'm an idiot so give me the step by step if your answer is "go grap X-dependency manager and then rtfm and you're set." Where do i find and dump files to make this line work:

import groovyx.net.http.HTTPBuilder

It says Groovy: unable to resolve class groovyx.net.http.HTTPBuilder

Also I am unable to import groovyx.net.http.ContentType.URLENC It says unable to resolve class groovyx.net.http.ContentType.URLENC

Update:

apparently you can uncomment the line mavenRepo "http://repository.codehaus.org" in BuildConfig.groovy


回答1:


Since you're talking about BuildConfig.groovy I assume the question is targeted at using HttpBuilder in a grails application. If so, you could either use

compile('org.codehaus.groovy.modules.http-builder:http-builder:0.5.0') {
        excludes "commons-logging", "xml-apis", "groovy"
}

in the dependencies-section of BuildConfig.groovy, or, even more easier, just install the rest plugin:

grails install-plugin rest



回答2:


Thom Nichols actually provided a helpful answer at http://groovy.329449.n5.nabble.com/problem-running-http-builder-code-td3995735.html to a similar question.

Basically, you can get into one of the snapshot directories at http://snapshots.repository.codehaus.org/org/codehaus/groovy/modules/http-builder/http-builder/ and download one of the packages ending with 'all'. Inside there, you'll find a dependencies directory that contains all the dependencies you need, which you can place in your lib directory. The root of the all zip (or tar) file should contain the main http-builder-#.#-SNAPSHOT.jar, which you should also place in lib.

I was doing this just from the Groovy Console. For Grails, I imagine Stefan's answer of just installing the Grails rest plugin is the best bet.




回答3:


try importing the .jar for HTTPBuilder-http://repository.codehaus.org/org/codehaus/groovy/modules/http-builder/http-builder/0.5.2/



来源:https://stackoverflow.com/questions/6552697/how-to-import-groovyx-net-http

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!