但是,我已经创建了自定义事件侦听器,它扩展了AbstractPersistenceEventListener,如Grails文档http://grails.org/doc/latest/guide/GORM.html中所述,它工作正常。如果执行如下操作,我无法在此侦听器中注入Service。无法在src/groovy中注入grails应用上下文
def context = ServletContextHolder.servletContext.getAttribute(GrailsApplicationAttributes.APPLICATION_CONTEXT)
def myService = context.myService
'context'返回null。
任何想法可能是什么问题。谢谢 p.s. GRails 2.1.2
上下文返回null或上下文为空? – 2013-04-18 12:31:34
对不起,我的英文。上下文为null或ServletContextHolder.servletContext.getAttribute(GrailsApplicationAttributes.APPLICATION_CONTEXT)返回null – latvian 2013-04-18 13:00:58