Recently, I had the opportunity to use Grails at work, and since I was reading the official document, I will write about Config related (including my own memorandum ...)
It is divided into two main areas: build settings and runtime settings.
Build settings are generally done in Gradle and build.gradle. Runtime settings are done in the grails-app / conf / application.yml file by default
grails.enable.native2ascii Set this to false if you don't need the native2ascii conversion of the Grails i18n properties file (default: true).
grails.views.default.codec Set the default encoding system of GSP Either'none','html', or'base64' (default:'none'). Set this to'html' to reduce the risk of XSS attacks.
grails.views.gsp.encoding File encoding used for GSP source files (default:'utf-8').
grails.mime.file.extensions Whether Content Negotiation uses the file extension to determine the MIME type (default is true).
grails.mime.types Settings for supporting MIME type maps for use in content negotiation.
grails.serverURL A string that specifies the server URL part of the absolute link, including the server name. This setting is also used for redirects. See documentation for details
grails.views.gsp.sitemesh.preprocess Whether to preprocess SiteMesh. Disabling it slows down page rendering, but if you need SiteMesh to parse the HTML generated from the GSP view, disable it.
By setting these directives, the reload behavior of the project-specific source file is determined. Each directive receives a list of strings representing the class name of the project's source file that should be excluded from the reload operation or included when running the application under development with the run-app command. For example, if the grails.reload.include directive is set, only the classes included in that list will be reloaded. (Grails.reload.excludes, on the contrary, reloads everything except the included classes)
If you want to read the runtime settings, that is, the settings defined in application.yml, use the grailsApplication object that can be used as a variable in the controller or tag library. The config property of the grailsApplication object is an instance of the Config interface and It provides many methods to read the settings. For example, the getProperty method is useful for efficiently getting configuration properties while specifying a property type (default type is String) and providing default fallback values.
Dynamic access to settings at run time can have a small impact on application performance. Another approach is to implement the GrailsConfigurationAware interface. If you feel like it, I will add it or post an article. .. ..
Recommended Posts