Grails 覆盖插件Impl
有 插件Grails 覆盖插件Impl,grails,grails-plugin,Grails,Grails Plugin,有 插件 class MyService { String getFrom(){ return 'Service from plugin'} } class MyBean { String getFrom(){ return 'Bean from plugin'} } 应用程序 class MyAppBean { String getFrom(){ return 'Bean from App'} } package myappwithmyplugin class My
class MyService {
String getFrom(){ return 'Service from plugin'}
}
class MyBean {
String getFrom(){ return 'Bean from plugin'}
}
应用程序
class MyAppBean {
String getFrom(){ return 'Bean from App'}
}
package myappwithmyplugin
class MyAppService {
String getFrom(){ return 'Service from App'}
}
资源.groovy
控制器
为什么结果是:
来自应用程序的Bean
从2.2开始,为了支持名称空间,Grails注册了插件bean名称和类bean服务的连接。要覆盖插件引入的服务,需要使用pluginNameServiceName 资料来源:
jira.grails.org/browse/grails-10091您使用的是哪个版本的grails?请查看此链接,也许您有这个问题@Alidad谢谢!你能重复一下你的评论作为回答吗。顺便说一下,它通过参考资料中的**myPluginMyService(MyAppService)**来解决
beans = {
myBean(MyAppBean){}
myService(MyAppService){}
}
class MyController {
def myBean
def myService
def index() {
println myBean.getFrom()
println myService.getFrom()
}
}