Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Importing services in the Grails console?

How do I get the services in the grails console? My business rules are implemented in services but I don't have access to them in the grails console. Does anyone know how to help me?

like image 292
isilva Avatar asked Oct 04 '12 18:10

isilva


1 Answers

The Spring ApplicationContext is available as the ctx variable in the console, and you can use this to access Spring beans such as services. Typically that would be def myService = ctx.getBean('myService') but Grails adds a metaclass helper so you can just do def myService = ctx.myService

like image 189
Burt Beckwith Avatar answered Oct 23 '22 07:10

Burt Beckwith