简体   繁体   English

Groovy缺少方法异常

[英]missing method exceptions with Groovy

I am new to groovy. 我是新手。 I have a code like this. 我有这样的代码。

String flavor 串味

HashMap config = new HashMap([ ttl: 0, url: url, appName: appName, enable: true ])
client.put("${data}.json", config)

From this client Map I need to iterate the values of appName and enable. 我需要从此客户端Map迭代appName的值并启用。 For that I used get method... I am not sure about this. 为此,我使用了get方法...对此我不确定。

def values = client.get("${data}.json");

while using this get method am getting following error. 使用此get方法时出现以下错误。 Since I am new to groovy i don't know what is happening here 由于我是新手,所以我不知道这里发生了什么

groovy.lang.MissingMethodException: No signature of method: com.comcast.csv.haxor.SecureFirebaseRestClient.get() is applicable for argument types: (org.codehaus.groovy.runtime.GStringImpl) values: [testJson.json] groovy.lang.MissingMethodException:方法的无签名:com.comcast.csv.haxor.SecureFirebaseRestClient.get()适用于参数类型:(org.codehaus.groovy.runtime.GStringImpl)值:[testJson.json]
Possible solutions: get(com.comcast.tvx.megahttp.utils.URL, java.lang.Class), get(java.lang.String, java.lang.Class), grep(), grep(java.lang.Object), getAt(java.lang.String), wait() 可能的解决方案:get(com.comcast.tvx.megahttp.utils.URL,java.lang.Class),get(java.lang.String,java.lang.Class),grep(),grep(java.lang.Object) ),getAt(java.lang.String),wait()

not sure what you are trying to do, but (without knowing other details) I'd put your code that way: 不确定您要做什么,但是(不知道其他详细信息)我将以这种方式放置您的代码:

Map config = [ ttl: 0, url: url, appName: appName, enable: true ]
client[ "${data}.json" ] = config
def values = client[ "${data}.json" ]

assuming, that you wanted to use getAt() (short-cut with [] ) method instead of get() 假设您想使用getAt() (使用[]快捷方式)而不是get()

Try this: 尝试这个:

def config = [ ttl: 0, url: url, appName: appName, enable: true ]
def endpoint = "${data}.json" as String

client.put(endpoint, config)
def values = client.get(endpoint, HashMap)

def appName = values.appName
def enable = values.enable

I couldn't find any info on SecureFirebaseRestClient , so I'm guessing about how it works. 我在SecureFirebaseRestClient上找不到任何信息,所以我正在猜测它的工作方式。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM