grails - 覆盖插件Impl

标签 grails grails-plugin



插件

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/

相关文章:

grails - Spring Security密码验证(密码中的特殊字符)

grails - Grails3集成测试失败并显示错误

json - 在Grails中将模型作为JSON返回时如何处理延迟加载的引用

jquery - Twitter Bootstrap 下拉菜单在部署时不起作用

grails - Grails Controller 和继承/关闭

grails - 如何在Grails中使用自定义错误消息创建自定义验证器?

unit-testing - 如何使用脚手架模板 Test.groovy 为 Controller 生成单元测试?

spring - 编译期间发生 fatal error org.springframework.beans.factory.BeanDefinitionStoreException

grails - Grails&Gradle:插件管理