Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/grails/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Grails 覆盖插件Impl_Grails_Grails Plugin - Fatal编程技术网

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()
    }
}