我在Bootstrap.groovy中有以下代码: -
class BootStrap {
def dataLoaders;
def init = { servletContext ->
startLoaders();
}
def startLoaders() {
for (IDataLoader loader : dataLoaders) {
runAsync {
loader.setup();
loader.startLoading();
}
}
}
}
当我运行应用程序时,抛出以下异常:
ERROR org.codehaus.groovy.grails.web.context.GrailsContextLoader Error initializing the application: No signature of method: BootStrap.runAsync() is applicable for argument types: (BootStrap$_startLoaders_closure3) values: [BootStrap$_startLoaders_closure3@6892f97b]
groovy.lang.MissingMethodException: No signature of method: BootStrap.runAsync() is applicable for argument types: (BootStrap$_startLoaders_closure3) values: [BootStrap$_startLoaders_closure3@6892f97b]
at BootStrap.startLoaders(BootStrap.groovy:27)
at BootStrap$_closure1.doCall(BootStrap.groovy:15)
我已将以下内容添加到BuildConfig.groovy的插件部分:
compile ":executor:0.3"
答案 0 :(得分:1)
请改为尝试:
class BootStrap {
def dataLoaders
def executorService
def init = { servletContext ->
startLoaders()
}
def startLoaders() {
for (IDataLoader loader : dataLoaders) {
executorService.submit({
loader.setup()
loader.startLoading()
} as Callable)
}
}
}