2013-10-10 34 views
1

覆蓋插件默認地將Impl

插件

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

爲什麼一個結果是:

比恩從應用

從插件服務

+0

您正在使用的Grails的版本? – Alidad

+0

Loading Grails 2.2.1 –

+1

結帳這個鏈接也許你有這個問題http://jira.grails.org/browse/GRAILS-10091 – Alidad

回答

2

作爲2.2,以支持命名空間,Grails的寄存器串接插件bean名稱和bean之類的服務。要覆蓋插件引入的服務,您需要使用pluginNameServiceName。

來源: jira.grails.org/browse/GRAILS-10091