[英]grails 2.2.2 service don't know domain model: “No signature of method”
I have a grails-plugin called "listadmin" there is a domain model "Liste": 我有一个名为“ listadmin”的grails插件,有一个域模型“ Liste”:
package listadmin
class Liste {
String internal_name
String public_name
Boolean edtiable = true
Boolean visible = true
static hasMany = [eintrage : ListenEintrag]
static constraints = {
internal_name(unique : true , blank : false);
}
String toString() {
"${public_name}"
}
}
I have service called "SECO_ListenService" in the same module (grails-plugin): 我在同一模块(grails-plugin)中有一个名为“ SECO_ListenService”的服务:
package listadmin
class SECO_ListenService {
def getEntriesOfList(String intnalListName) {
def aList = Liste.findByInternal_name(intnalListName)
return aList
}
}
Now I try to call this service from an other module (grails-plugin) called "institutionadmin". 现在,我尝试从另一个名为“ institutionadmin”的模块(grails-plugin)中调用此服务。 The SECO_ListenService should return a list of strings for an select of a domain model in the inistitutionadmin:
SECO_ListenService应该返回inistitutionadmin中用于选择域模型的字符串列表:
package institutionadmin
import listadmin.SECO_ListenService
class Einrichtung {
Long einrichtungs_type
Long type_of_conzept
int anzahl_gruppen
int anzahl_kinder_pro_Gruppe
String offnungszeiten
static hasMany = [rooms : Raum]
static constraints = {
def aList = []
def sECO_ListenService = new SECO_ListenService()
aList=sECO_ListenService.getEntriesOfList("einrichtung_type")
einrichtungs_type(inList: aList)
}
}
If I try to run this application with the both modules. 如果我尝试同时使用两个模块运行此应用程序。 I get the following error:
我收到以下错误:
Caused by MissingMethodException: No signature of method: listadmin.Liste.methodMissing() is applicable for argument types: () values: []
由MissingMethodException引起:方法没有签名:listadmin.Liste.methodMissing()适用于参数类型:()值:[]
It seemed to be that the service class don't know the "Liste"-domain-model. 服务类似乎不知道“ Liste”域模型。 But I don't know where the error is.
但是我不知道错误在哪里。 I also tried to call other standard methods like "findAll" but without any success.
我还尝试调用其他标准方法,例如“ findAll”,但没有成功。
Has anybody an idea where my mistake could be? 有人知道我的错误可能在哪里吗?
To get a service in a static context you need to access the grailsApplication
spring bean. 为了在静态上下文中获得服务,您需要访问
grailsApplication
spring bean。 This can be done thought Holders
. Holders
可以做到这一点。 Example: 例:
class MyService {
List<String> getAvailable() {
return ['A','B','C']
}
}
class MyDomainClass {
String something
static constraints = {
something inList: getSomethingList()
}
static List<String> getSomethingList() {
def myService = Holders.grailsApplication.mainContext.getBean('myService')
return myService.getAvailable()
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.