2

私は groovy にかなり慣れていません。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
}

私が得ている例外:

 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]

したがって、基本的には http-builder をダウンロードしていないため、RESTClient タイプの署名が見つかりません。

私のグルーヴィーなバージョンは: 2.6.0-alpha-1 Intellij バージョン: 2017.2.3

groovy または intellij IDE で Grape を開始するものはありますか? 誰か助けてください。私はここで立ち往生しています。

4

2 に答える 2