有
插件
class MyService {
String getFrom(){ return 'Service from plugin'}
}
class MyBean {
String getFrom(){ return 'Bean from plugin'}
}
APP
class MyAppBean {
String getFrom(){ return 'Bean from App'}
}
package myappwithmyplugin
class MyAppService {
String getFrom(){ return 'Service from App'}
}
resources.groovy
beans = {
myBean(MyAppBean){}
myService(MyAppService){}
}
控制者
class MyController {
def myBean
def myService
def index() {
println myBean.getFrom()
println myService.getFrom()
}
}
为什么会是:
来自应用程序的Bean
来自插件的服务
最佳答案
从2.2版本开始,为了支持命名空间,Grails会注册插件bean名称和像服务这样的bean的串联。要覆盖插件引入的服务,您需要使用pluginNameServiceName。
资源:
jira.grails.org/browse/GRAILS-10091
关于grails - 覆盖插件Impl,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19292571/