[Grails] About the setting area and the setting items of application.yml

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

Grails configuration area

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

Settings in application.yml

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.

grails.reload.excludes and grails.reload.include

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)

bonus

Load application.yml settings

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

[Grails] About the setting area and the setting items of application.yml
About the operation of next () and nextLine ()
About next () and nextLine () of the Scanner class
[Technical memo] About the advantages and disadvantages of Ruby
About the same and equivalent
[Java] I thought about the merits and uses of "interface"
This and that of the JDK
About the role of the initialize method
About removeAll and retainAll of ArrayList
Think about the 7 rules of Optional
About the log level of java.util.logging.Logger
About the classification and concept of Immutable / Mutable / Const / Variable of Java and Kotlin.
[Ruby basics] About the role of true and break in the while statement
(Determine in 1 minute) About the proper use of empty ?, blank? And present?
Folding and unfolding the contents of the Recyclerview
About the initial display of Spring Framework
About the treatment of BigDecimal (with reflection)
About the difference between irb and pry
About the number of threads of Completable Future
[Android] List all setting items on the setting screen
[Java] The confusing part of String and StringBuilder
I compared the characteristics of Java and .NET
Learn the rudimentary mechanism and usage of Gradle 4.4
About call timing and arguments of addToBackStack method
What are the advantages of DI and Thymeleaf?
A note about the Rails and Vue process