We are upgrading grails 2.4.4 to 3.6.6, but the code failed at grailsApplication.config.grails.binRange. Any idea why I am not able to access grails from config. anyone can solve this?
The default configuration file for Grails 3 applications is grails-app/conf/application.yml
. In this file, YAML syntax is supported.
The GrailsApplication interface defines the getConfig
method which returns a Config object. In the Spring application context is a bean named grailsApplication
which is an instance of a class which implements the GrailsApplication
interface. Retrieving the config object from this bean is one way to gain access to config values.
For Example: grails-app/conf/application.yml
max:
line:
numbers: 42
OR
max.line.numbers: 42
grails-app/init/BootStrap.groovy
import grails.core.GrailsApplication
class YourController{
GrailsApplication grailsApplication
// retrieve the max.line.numbers config value
def maxLineNumbers = grailsApplication.config.getProperty('max.line.numbers')
}
Hope this will helps you