【问题标题】:import groovyx.net.http.RESTClient in Groovy class在 Groovy 类中导入 groovyx.net.http.RESTClient
【发布时间】:2014-01-31 18:21:55
【问题描述】:

我尝试在我的 groovy 类中导入 groovyx.net.http.RESTClient。 我的 groovy 类是这样的:

void getREST() {

    def r = new RESTClient(url) 
    def response = r.get(path:'test',headers:['Authorization': "auth"] )   
    println "RESPONSE"  
    println response.headers
    response.headers.each { it ->
        println it
    }

}

在我的课堂上,我像这样导入 RESTClient:

    import groovyx.net.http.RESTClient 

但是,我收到“无法解析类 groovyx.net.http.RESTClient”错误。我正在使用 NetBeans IDE 7.4。

我已经使用以下代码配置了 BuildConfig.groovy:

    compile ":rest:0.8"

并添加 maven 存储库:

    mavenRepo "http://repository.codehaus.org/"

但我仍然无法导入 RESTClient。我该怎么办?

【问题讨论】:

  • 添加插件后你complie应用了吗?还是刷新依赖?
  • 修复它。只需再添加一个:mavenRepo "grails.org/plugins"。这很有趣,文档中没有提到这个 repo...
  • 不。您真正想要的是 [Grails Rest Client Builder][1]。 [1]:stackoverflow.com/a/24360224/30818

标签: grails


【解决方案1】:

修复它。只需向 BuildConfig 添加一个 repo:

mavenRepo "http://grails.org/plugins"

【讨论】:

  • Grails 会抛出错误:There was an error loading the BuildConfig: no protocol: grails.org/plugins
  • @ivarPrudnikov 是评论的复制和粘贴,在 cmets SO 中隐藏了链接前面的 http://...
  • 感谢@IanRoberts - 已修复
猜你喜欢
  • 2011-07-10
  • 1970-01-01
  • 1970-01-01
  • 2015-01-18
  • 1970-01-01
  • 2012-06-29
  • 2019-07-27
  • 2015-02-20
  • 1970-01-01
相关资源
最近更新 更多