我有一个像这样的简单脚本...
def createEntry(service){
...
}
class Service {
...
void create(){
createEntry(this)
}
}
但是当我运行这段代码时,我得到以下信息...
hudson.remoting.ProxyException:groovy.lang.MissingMethodException:方法的无签名:Service.createEntry()适用于参数类型:(Service)值:[Service @ 64bbfb0d]
答案 0 :(得分:0)
使用您的文件名作为类。
例如,您的groovy文件类似于filename.groovy
,则可以使用Java类中的方法,如下所示。
我希望这段代码可以澄清您的问题:
static void m(){
println('hai')
}
class A {
static void a()
{
filename.m() // the file name you use
}
}
A.a()
答案 1 :(得分:0)
我在Groovy论坛上找到了这个答案。
这很可怕,但至少有可能...
def g = { x, y -> x * y }
class MyFunc {
def fun
def run(x, y) { fun(x, y) }
}
def fn = new MyFunc(fun: g)
println fn.run(4, 9)