如何导入 groovyx.net.http
我不明白 Maven 或 Grape,而且我是个白痴,所以如果你的答案是“先去 grap X-dependency manager,然后 rtfm,你就设置好了”,请给我一步一步的信息。我在哪里找到并转储文件以使该行工作:
import groovyx.net.http.HTTPBuilder
它说 Groovy: 无法解析类 groovyx.net.http.HTTPBuilder
另外,我无法导入 groovyx.net.http。 ContentType.URLENC
它说无法解析类groovyx.net.http.ContentType.URLENC
更新:
显然你可以取消注释行mavenRepo BuildConfig.groovy 中的“http://repository.codehaus.org”
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
既然您正在谈论 BuildConfig.groovy,我假设问题的目标是在 grails 应用程序中使用 HttpBuilder。如果是这样,您可以
在 BuildConfig.groovy 的依赖项部分中使用,或者更简单,只需安装 休息插件:
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
in the dependencies-section of BuildConfig.groovy, or, even more easier, just install the rest plugin:
尝试导入 HTTPBuilder- 的 .jar http://repository.codehaus.org/org/codehaus/groovy/modules/http-builder/http-builder/0.5.2/
try importing the .jar for HTTPBuilder-http://repository.codehaus.org/org/codehaus/groovy/modules/http-builder/http-builder/0.5.2/
Thom Nichols 实际上在 http://groovy.329449.n5.nabble.com/problem-running-http-builder-code-td3995735.html 类似的问题。
基本上,您可以进入 http://snapshots.repository.codehaus.org/org/codehaus/groovy/modules/http-builder/http-builder/ 并下载以结尾的软件包之一 '全部'。在其中,您将找到一个依赖项目录,其中包含您需要的所有依赖项,您可以将其放置在 lib 目录中。所有 zip(或 tar)文件的根目录应包含主 http-builder-#.#-SNAPSHOT.jar,您还应将其放置在 lib 中。
我只是从 Groovy 控制台执行此操作。对于 Grails,我想 Stefan 的回答是安装 Grails 休息插件是最好的选择。
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.