无法在grails中安装http-builder

时间:2015-01-12 16:33:19

标签: grails httpbuilder

我的grails 2.3.6应用程序中有一个奇怪的行为。

我想使用groovyx.net.http.HTTPBuilder,但IDE报告它无法解析该类。

所以,我在BuildConfig.groovy中添加了以下行:

build "org.codehaus.groovy.modules.http-builder:http-builder:0.7"

但我得到以下例外:

$ grails run-app MyApp
| Configuring classpath
| Error Resolve error obtaining dependencies: Could not find artifact org.codehaus.groovy.modules.http-builder:http-builder:zip:0.7 in grailsCentral (http://repo.grails.org/grails/plugins) (Use --stacktrace to see the full trace)
| Error Could not find artifact org.codehaus.groovy.modules.http-builder:http-builder:zip:0.7 in grailsCentral (http://repo.grails.org/grails/plugins)
| Run 'grails dependency-report' for further information.

BuildConfig.groovy中的我的存储库:

mavenRepo "http://repository.codehaus.org"
mavenRepo "http://download.java.net/maven/2/"
mavenRepo "http://repo.spring.io/milestone/"
mavenRepo "http://www.hibernatespatial.org/repository"
mavenRepo "https://oss.sonatype.org/content/groups/public/"
mavenRepo "http://repo.grails.org/grails/core"

奇怪的是它应该在那里:http://repo.grails.org/grails/webapp/search/artifact/?1&q=http-builder

有什么想法?我清理了,删除了〜/ .m2,〜/。groovy,〜/ .grails

谢谢!

1 个答案:

答案 0 :(得分:3)

问题在于您的依赖关系的范围,它应该是compile而不是build。换句话说,替换此

build "org.codehaus.groovy.modules.http-builder:http-builder:0.7"

compile "org.codehaus.groovy.modules.http-builder:http-builder:0.7"

如果您仍然遇到问题,请将BuildConfig.groovythis one交叉引用,这正确地声明了对此库的依赖。