Tus*_*mar 2 grails groovy intellij-idea ruby-grape groovy-console
我对 groovy 很陌生,ans 正在练习使用 http-builder 包进行 REST 调用,我正在尝试使用 @Grab 注释添加依赖项,但它没有下载依赖项,注释不起作用,
我的代码:
import groovyx.net.http.ContentType
import groovyx.net.http.RESTClient
@Grab(group='org.codehaus.groovy.modules.http-builder', module='http-builder', version='0.7' )
def restClient = RESTClient('http://api.icmdb.com')
restClient.contentType = ContentType.JSON
restClient.get(path:'/jokes/random'){response,json->
println response.status
println json
}
Run Code Online (Sandbox Code Playgroud)
我得到的例外:
Caught: groovy.lang.MissingMethodException: No signature of method: com.groovy.practice.RESTCall.RESTClient() is applicable for argument types: (String) values: [http://api.icmdb.com]
groovy.lang.MissingMethodException: No signature of method: com.groovy.practice.RESTCall.RESTClient() is applicable for argument types: (String) values: [http://api.icmdb.com]
Run Code Online (Sandbox Code Playgroud)
所以基本上它没有下载http-builder,因此它没有找到RESTClient类型的签名。
我的常规版本是:2.6.0-alpha-1 Intellij 版本:2017.2.3
有什么可以在 groovy 或 intellij IDE 中启动 Grape 的,任何人都可以帮忙,我被困在这里。
| 归档时间: |
|
| 查看次数: |
1744 次 |
| 最近记录: |