Grails: Accessing spring beans in the destory closure of Bootstrap code?

后端 未结 3 708
一生所求
一生所求 2020-12-17 01:19

I\'m looking to access a bean in my destroy closure in the Bootstrap.groovy of my grails project. Any ideas on how to achieve this?

I seem to have no access to servl

3条回答
  •  星月不相逢
    2020-12-17 02:26

    I know I'm all late here and all but since I found this via Google...

    Your BootStrap class gets injected with Spring beans by name, just like all the services and controllers and stuff. If you want a bean, just def it by name and it'll show up. Otherwise, just def grailsApplication and go to grailsApplication.mainContext.getBean etc.

提交回复
热议问题