【问题标题】:Cannot install http-builder in grails无法在 grails 中安装 http-builder
【发布时间】:2015-01-12 16:33:18
【问题描述】:

我的 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

谢谢!

【问题讨论】:

  • 很奇怪。它对我有用。我使用 runtime('org.codehaus.groovy.modules.http-builder:http-builder:0.7.1') 作为依赖项。
  • 别人下载的,所以不是代理?这是通过 maven 还是 ivy?
  • 0.7 在这里工作。你把它放在plugins而不是dependencies吗?

标签: grails httpbuilder


【解决方案1】:

问题是你的依赖范围,它应该是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 交叉引用,它正确地声明了对该库的依赖关系。

【讨论】:

  • 谢谢@Donal!我在“插件”而不是“依赖项”中有引用。然而,IDE 继续将 HttpBuilder 标记为红色“无法解析”,但运行应用程序会通过。
  • @elkarel 我猜你正在使用 Eclipse?它对 Grails 的支持不是很可靠 IMO,它经常报告这样的虚假错误
  • 是的,IDE 基于 Eclipse 及其明显的项目策略:-/ 谢谢!
猜你喜欢
  • 2016-05-22
  • 2011-10-12
  • 2015-04-27
  • 1970-01-01
  • 2014-10-20
  • 1970-01-01
  • 2013-11-13
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多