Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting application config in doWithSpring closure with a Grails 3 application

Grails 3 allows authors to use startup hooks similar to the ones provided to Grails 2 plugins. I'm looking at defining beans in the doWithSpring closure, and I'd like to pass values into a new bean based on some configuration values. I can't figure out, however, how to get the grailsApplication instance or the application configuration. How do you do this with Grails 3?

like image 466
BudJB Avatar asked Oct 19 '22 14:10

BudJB


1 Answers

Your plugin should extend grails.plugins.Plugin which defines the getConfig() method. See https://github.com/grails/grails-core/blob/9f78cdf17e140de37cfb5de6671131df3606f2fe/grails-core/src/main/groovy/grails/plugins/Plugin.groovy#L65.

You should be able to just refer to the config property.

Likewise you can refer to the inherited grailsApplication property which is defined at https://github.com/grails/grails-core/blob/9f78cdf17e140de37cfb5de6671131df3606f2fe/grails-core/src/main/groovy/grails/plugins/Plugin.groovy#L47.

I hope that helps.

like image 200
Jeff Scott Brown Avatar answered Oct 22 '22 21:10

Jeff Scott Brown