Dependency injection in the Grails Console

If you have a service named MyService with a function named HelloWorld, you can access it via dependency injection by adding

def MyService
def result = MyService.HelloWorld()

But to test in the console you need to do this:

def service = ctx.getBean("MyService")
def result = service.HelloWorld()
This entry was posted in Grails. Bookmark the permalink.

Comments are closed.