在grails progect上我想构建一个二进制插件,在每个特定项目上都可以实现“hook”
二进制插件结构
MyService (service) MyHookClassInterface myHookClass MyHookServiceInterface myHookService MyHookClassInterface (interface) MyHookServiceInterface (interface)
主要项目结构
ProjectHookClass impements MyHookClassInterface (groovy class) ProjectHookService impements MyHookServiceInterface (service) resources.groovy beans = { myHookClassInterface(ProjectHookClass) myHookServiceInterface(ProjectHookService) }
该解决方案就像使用源插件的魅力一样,但不会在二进制模式下注入MyService依赖。 我也启动了grails控制台并且ctx.getBean('myHookClassInterface')返回:
org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'myHookClassInterface' is defined at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeanDefinition(DefaultListableBeanFactory.java:529) at org.springframework.beans.factory.support.AbstractBeanFactory.getMergedLocalBeanDefinition(AbstractBeanFactory.java:1095) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:277) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:269) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193) at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1093) at org.springframework.beans.factory.BeanFactory$getBean.call(Unknown Source) at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:42) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116) at ConsoleScript0.run(ConsoleScript0:1)
THX
的Fabio
答案 0 :(得分:1)
已解决:该问题与二进制插件上resources.groovy的存在有关。在这种情况下,grails启动过程无法合并插件和项目resources.groovy。如果可以的话,请删除插件的resources.groovy。