Question
I'm completely new to Griffon and have simple question I surprised I couldn't found the answer...
How I can access my per environment settings I defined in Config.groovy
in the service.
environments {
development {
awserver.url = "http://localhost:8080/app"
}
production {
awserver.url = "xxx"
}
}
I tried injecting griffonApplication
(in analogy with grails) and use griffonApplication.config, but nothing seems to be working
Solution
The environmental settings are automatically merged in the application's config. Services (as any other GriffonArtifact) have a GriffonApplication property whose name is "app", so the following should work
class SampleService {
def serviceMethod() {
URL url = app.config.awserver.url.toURL()
// do something with url
}
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow