Grails groovy.lang.MissingMethodException:方法com.x.License.add()的签名不适用于参数类型:(com.x.License)值
我经常使用计划作业检索许可证。检索每个许可证的许可证时,我希望将该许可证添加到每个帐户的哈希映射中。在hashmap中,我有一个帐户和一个许可证列表。对于每个许可证,我尝试检查hashmap中是否已经有一个许可证列表,如果没有,我会创建一个新的列表,这样就可以了。但是,如果有一个列表,我会尝试将它添加到该列表中,并且由于某种原因它会抛出一个错误Grails groovy.lang.MissingMethodException:方法com.x.License.add()的签名不适用于参数类型:(com.x.License)值,grails,groovy,Grails,Groovy,我经常使用计划作业检索许可证。检索每个许可证的许可证时,我希望将该许可证添加到每个帐户的哈希映射中。在hashmap中,我有一个帐户和一个许可证列表。对于每个许可证,我尝试检查hashmap中是否已经有一个许可证列表,如果没有,我会创建一个新的列表,这样就可以了。但是,如果有一个列表,我会尝试将它添加到该列表中,并且由于某种原因它会抛出一个错误 licenses.each{license-> List<License> licensesPerAccount =
licenses.each{license->
List<License> licensesPerAccount = accountLicenseMap.get(license.account)
log.info("initial licenseperaccount " + licensesPerAccount)
if(licensesPerAccount == null) {
accountLicenseMap.put(license.account, license as List<License>)
} else{
log.info("licenseperaccount in else is " + licensesPerAccount)
licensesPerAccount.push(license)
log.info("licenseperaccount now is " + licensesPerAccount)
accountLicenseMap.put(license.account, licensesPerAccount)
}
}
许可证。每个{license->
List licensesPerAccount=accountLicenseMap.get(license.account)
log.info(“初始许可证持有人帐户”+许可证持有人帐户)
如果(licensesPerAccount==null){
accountLicenseMap.put(license.account,许可证列表)
}否则{
log.info(“else中的licenseperaccount为”+licensesPerAccount)
licensesPerAccount.push(许可证)
log.info(“licenseperaccount现在是”+licensesPerAccount)
accountLicenseMap.put(license.account,licensesPerAccount)
}
}
这是它抛出的错误:
错误2017-12-27 10:12:59045 grails.plugins.quartz.listeners.ExceptionPrinterJobListener-作业中发生异常:grails作业
org.quartz.JobExecutionException:groovy.lang.MissingMethodException:方法:com.x.License.add()的签名不适用于参数类型:(com.x.License)值:[com.x.License:10]
可能的解决方案:any()、find(com.x.License)、any(groovy.lang.Closure)、wait()、last()、save()
位于grails.plugins.quartz.GrailsJobFactory$GrailsJob.execute(GrailsJobFactory.java:111)
位于org.quartz.core.JobRunShell.run(JobRunShell.java:202)
位于org.quartz.siml.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:573)
原因:groovy.lang.MissingMethodException:方法:com.x.License.add()的签名不适用于参数类型:(com.x.License)值:[com.x.License:10]
可能的解决方案:any()、find(com.x.License)、any(groovy.lang.Closure)、wait()、last()、save()
位于org.codehaus.groovy.runtime.ScriptBytecodeAdapter.unwrap(ScriptBytecodeAdapter.java:58)
位于org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite$pogometamethodsiteNounwrapnocerc.invoke(PogoMetaMethodSite.java:253)
位于org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite.call(PogoMetaMethodSite.java:71)
位于org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:125)
在com.x.NewLicenseJob$\u execute\u closure1$$EQezpeTI.doCall(NewLicenseJob.groovy:32)
位于sun.reflect.GeneratedMethodAccessor629.invoke(未知源)
在sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)中
位于java.lang.reflect.Method.invoke(Method.java:497)
位于org.springsource.loaded.ri.reloadeTypeInvoker$2.invoke(reloadeTypeInvoker.java:133)
位于org.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1461)
位于org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:93)
位于groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325)
位于org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:294)
位于groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1021)
调用groovy.lang.Closure.call(Closure.java:426)
在com.x.NewLicenseJob$\u execute\u closure1.call(NewLicenseJob.groovy)上
调用(Closure.java:442)
在com.x.NewLicenseJob$\u execute\u closure1.call(NewLicenseJob.groovy)上
位于org.codehaus.groovy.runtime.DefaultGroovyMethods.each(DefaultGroovyMethods.java:2030)
位于org.codehaus.groovy.runtime.DefaultGroovyMethods.each(DefaultGroovyMethods.java:2015)
位于org.codehaus.groovy.runtime.DefaultGroovyMethods.each(DefaultGroovyMethods.java:2056)
位于org.codehaus.groovy.runtime.dgm$162.invoke(未知源)
位于org.codehaus.groovy.runtime.callsite.PojoMetaMethodSite$pojoMetamethodSiteNounwrapnocerc.invoke(PojoMetaMethodSite.java:274)
位于org.codehaus.groovy.runtime.callsite.PojoMetaMethodSite.call(PojoMetaMethodSite.java:56)
位于org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:125)
在com.x.NewLicenseJob$$EQezpeT2.execute上(NewLicenseJob.groovy:25)
在sun.reflect.NativeMethodAccessorImpl.invoke0(本机方法)处
位于sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
在sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)中
位于java.lang.reflect.Method.invoke(Method.java:497)
位于org.springsource.loaded.ri.reloadeTypeInvoker$2.invoke(reloadeTypeInvoker.java:133)
位于org.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1461)
位于grails.plugins.quartz.GrailsJobFactory$GrailsJob.execute(GrailsJobFactory.java:104)
... 省略了2个公共框架
这就是它记录的内容:
信息2017-12-27 10:12:59029 grails.app.jobs.com.x.NewLicenseJob-初始LicenseAccount空
2008年10月8月8月8月8月8月8月8月8月8月8月8月8月8月8月8月8月8月8月8月4月4月4月0月0月8月8月8月8月8月8月8月8月8月8月8月8月8月8月8月8月8月8月8月8月8月8月8月8月8月8月8月8月8月8日,国家政府:政府:政府:政府:政府:政府:政府:政府:政府:政府:政府:政府:政府:政府:政府:政府:政府:政府:政府:政府:政府:政府:政府:政府:政府:政府:政府:政府:政府:政府:政府:政府:政府:政府:政府:政府:政府:政府:政府:政府:政府:政府:政府:政府:政府:政府:政府:政府:政府:政府:政府:政府:政府:政府:政府:政府:政府:政府:政府:政府:政府:政府:政府:政府_4_0_,account0.default\u date\u pattern为default\u 9\u 4\u 0,account0.default\u date\u time\u pattern为default 10\u 4\u 0,account0.default\u time\u pattern为default 11\u 4\u 0,account0.default\u时区为default 12\u 4\u 0,account0.default\u视图为default 13\u 4\u 0,account0.deleted为deleted 14\u 4\u 0,account0.display为decimal\u显示为decimal,account0。即时反馈为instant16\u 4\u 0\u,account0\u。语言为languag17\u 4\u 0\u,account0\u。匹配\u注册表
List<License> licenseList = []
licenseList << license
accountLicenseMap.put(license.account, licenseList)