简体   繁体   中英

code fail at grailsApplication.config.grails.binRange. any one can solve this?

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')

}

Reference this and this

Hope this will helps you

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM