从grails项目中执行(在控制台中):import vine.*
import grails.converters.JSON
s = Stem.makeStem([name: "nameValue", description: "Description value"], "24601")
println s as JSON
产生:
groovy.lang.MissingMethodException: No signature of method: vine.Stem.makeStem() is applicable for argument types: (java.util.LinkedHashMap, java.lang.String) values: [[name:nameValue, description:Description value], BR-459] Possible solutions: makeStem(java.util.LinkedHashMap, java.lang.String) at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) at java.lang.reflect.Constructor.newInstance(Constructor.java:423) at org.springsource.loaded.ri.ReflectiveInterceptor.jlrConstructorNewInstance(ReflectiveInterceptor.java:1075) at org.codehaus.groovy.reflection.CachedConstructor.invoke(CachedConstructor.java:83) at org.codehaus.groovy.runtime.callsite.ConstructorSite$ConstructorSiteNoUnwrapNoCoerce.callConstructor(ConstructorSite.java:105)
方法定义:
def makeStem( LinkedHashMap h, String owner)
{
def s
if ( h.name && h.description ) {
s = new Stem(h)
def ra = new RoleAssignment(peoples: owner)
s.addRole(ra)
}
return s
}
我最初使用Map h进行了定义,但是那也不起作用。
有任何想法吗?
最佳答案
假设Stem是服务类。
您可以在Grails控制台中执行以下操作
import vine.*
import grails.converters.JSON
def stem= ctx.stem
s = stem.makeStem([name: "nameValue", description: "Description value"], "24601")
println s as JSON
假设Stem是一个域类,
static makeStem( LinkedHashMap h, String owner) // convert it to a static method
{
...
}
关于grails - Groovy/Grails没有方法签名,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40156472/