donguy76
donguy76

Reputation: 640

Calling grailsApplication inside a static method

In my class i have defined,

def grailsApplication;

Now inside a static method am trying to access it and it gives an error:

Groovy:Apparent variable 'grailsApplication' was found in a static scope but doesn't refer to a local variable, static field or class. Possible causes:

How can i access the grailsApplication inside a static method?

Upvotes: 0

Views: 1100

Answers (1)

injecteer
injecteer

Reputation: 20707

pass it as a method argument:

static someMethod( grailsApplication ){...}

Grails developers discourage using static tricks to access the app-context

Upvotes: 2

Related Questions