[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 the mechanism of the Web and HTTP
Think about the combination of Servlet and Ajax
About next () and nextLine () of the Scanner class
[Technical memo] About the advantages and disadvantages of Ruby
About the handling of Null
About the description of Docker-compose.yml
About the same and equivalent
[Ruby] Questions and verification about the number of method arguments
[Ruby] About the difference between 2 dots and 3 dots of range object.
[Java] I thought about the merits and uses of "interface"
About the behavior of ruby Hash # ==
About the basics of Android development
About fastqc of Biocontainers and Java
About the equals () and hashcode () methods
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
Summary about the introduction of Device
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?
About the version of Docker's Node.js image
What is testing? ・ About the importance of testing
Folding and unfolding the contents of the Recyclerview
[Swift] Get the height of Safe Area
About the initial display of Spring Framework
About the error message Invalid redeclaration of'***'
About the treatment of BigDecimal (with reflection)
About the difference between irb and pry
About the number of threads of Completable Future
Check the version of the JDK installed and the version of the JDK enabled
[Rails / ActiveRecord] About the difference between create and create!
About the official start guide of Spring Framework
About the idea of anonymous classes in Java
Compare the speed of the for statement and the extended for statement.
[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
Summary of Japan time setting and display method
[Ruby] Setting values ​​and memorandum for the table
A memo about the types of Java O/R mappers and how to select them