It’s a good practice to move all the re-usable configuration settings in the config file which can be read in controllers, tag-lib and services easily. Also you can get the application context in services, controllers and tag-lib easily for injecting the beans. But getting both in plain groovy and java classes is not the same. Here’s a simple way to get the main context and config in your groovy or java classes inside src folder.
For config:
for example, you have defined the date format in config for parsing the dates in your application like :


you can read this in your POGO or POJO like:

Object fromString(String s) {
return DateUtils.parseDate(s,[] as String[])

Lastly, to get the application context for injecting the beans you can use the same Holders class like: