在Grails中得配置文件放在conf文件下,当系统启动时候会默认读取Config.groovy等配置文件。
在Config.groovy中除过几个仅从key就可以看出作用的key,value键值或者script外,Grails还提供了如下几个可配置选项:
Grails also provides the following configuration options:
-
grails.config.locations
- The location of properties files or addition Grails Config files that should be merged with main configuration
-
grails.enable.native2ascii
- Set this to false if you do not require native2ascii conversion of Grails i18n properties files
-
grails.views.default.codec
- Sets the default encoding regime for GSPs - can be one of 'none', 'html', or 'base64' (default: 'none'). To reduce risk of XSS attacks, set this to 'html'.
-
grails.views.gsp.encoding
- The file encoding used for GSP source files (default is 'utf-8')
-
grails.mime.file.extensions
- Whether to use the file extension to dictate the mime type in Content Negotiation
-
grails.mime.types
- A map of supported mime types used for Content Negotiation
-
grails.serverURL
- A string specifying the server URL portion of absolute links, including server name e.g. grails.serverURL="http://my.yourportal.com". See createLink
.
1、grails.config.locations,这个选项可以让程序员自定义的*.properties文件或者*.groovy文件在系统启动后加载到主配置文件Config.groovy中。它的配置模板如下:
grails.config.locations = [ "classpath:${appName}-config.properties",
"classpath:${appName}-config.groovy",
"file:${userHome}/.grails/${appName}-config.properties",
"file:${userHome}/.grails/${appName}-config.groovy"]
if(System.properties["${appName}.config.location"]) {
grails.config.locations << "file:" + System.properties["${appName}.config.location"]
}
模板的配置说明:
2、grails.enable.native2ascii这个主要是用来自动转换properties文件内容的,如果你不用国际化支持的话,可以在配置文件中设置为false
3、grails.views.default.codec是设置GSP编码方式的,有三个值可选,分别是:'none','html','base64',默认是none,设置为base64可以降低被XSS攻击的风险
4、grails.views.gsp.encoding是设置GSP默认编码,默认是utf-8
5、配置log日志:
用Log4j
log4j = {
error 'org.codehaus.groovy.grails.web.servlet', // controllers
'org.codehaus.groovy.grails.web.pages' // GSP
warn 'org.mortbay.log' }
分享到:
相关推荐
您需要通过在log4j部分中添加以下代码来修改Config.groovy配置文件: appenders { console name: 'stdout', layout: pattern(conversionPattern: '%m%n') } info 'org.flywaydb' 配置 默认情况下,您应该将sql文件...
所以需要一些手动编辑:在 BuildConfig.groovy 中,编辑行:include(name: "angular/client/ "),替换 include(name: "extjs/client/ ") 在 bootstrap.groovy 中,更改 scaffold.InternalFrontendHelper....
带有Java JDK 1.7的最低Grails版本是2.3.7,并且依赖项具有以下版本: 核心JSF 2.2 Primefaces 5.2 Apache MyFaces 2.2.8 可以在上找到源代码安装通过在BuildConfig.groovy文件中设置插件依赖性,在任何Grails项目...
在BuildConfig.groovy中添加一个依赖项: grails . project . dependency . resolution = { // ... plugins { runtime ' :console:1.5.12 ' // ... } } 谷物3+ 注意:如果使用Grails 3.0.4,则需要将build....
在“插件”部分中将其添加到您的BuildConfig.groovy中。 compile ":java8-temporal:0.2" 数据绑定 该插件增加了对以下类型的绑定支持: 年 年月 当地时间 本地日期 LocalDateTime 立即的 ZonedDateTime JSON和...
Vaadin特定的UI与无缝Spring Security集成用于以Groovy方式构建UI的类无限制地在同一项目中使用Grails控制器,服务等安装只需BuildConfig.groovy下行添加到BuildConfig.groovy 。 compile " ...
在启动时,MongoDB插件将在您的计算机中查找“ mongo”配置属性Config.groovy文件,该文件定义您的MongoDB数据库和相关配置特性。 #Config.groovy mongo{ databases{ server1{ host = "localhost" port = 1234...
它还提供了一个强大的选择小部件(直接替代下拉框)安装将以下插件依赖项添加到您的BuildConfig.groovy repositories {.. . // required by a dependency of the export plugin mavenRepo " ...
用于 Open Dolphin 的 Grails 插件 该插件可帮助您使用 grails 开发 Open-Dolphin 应用... grails-app/conf/BuildConfig.groovy .. . grails . project . dependency . resolution = { .. . plugins { .. . comp
在webapp的BuildConfig.groovy中,在“插件”部分(位于文件末尾)下添加: compile ":akka:<version>" 并复制webapp lib文件夹下的插件zip,然后运行grails refresh-dependencies,grails clean和grails compile...
Grails 语言环境配置插件 [Grails Locale ...安装将以下插件依赖项添加到您的BuildConfig.groovy grails . project . dependency . resolution = { plugins { .. . compile ' :locale-configuration:1.1.1 ' .. . }} 在
在webapp的BuildConfig.groovy中,在“插件”部分(位于文件末尾)下添加: compile ":scala:<version>" 然后运行grails刷新依赖关系,grails clean,然后grails compile,应该安装插件。 如果插件安装期间发生...
一旦您输入了 Active Directory 配置 (grails-app/conf/Config.groovy),启动您的应用程序并通过登录控制器登录进行测试。 笔记 这使用 Grails 2.X 并且可能不适用于 3.X 您可能需要更新 ...
要安装,您需要将插件添加到 BuildConfig.groovy 中 compile " :redis-hibernate-cache:1.0 " 还有这个存储库到存储库列表: repositories { .. . mavenRepo " http://dl.bintray.com/debop/maven " } 这是下载...
6 章 在 Spring Boot 中使用 Grails ......936.1 使用 GORM 进行数据持久化 .................932 目 录6.2 使用 Groovy Server Pages 定义视图 .......986.3 结合 Spring Boot 与 Grails 3 .................1006.3...
在计算grailsApplication ,您将获得grailsApplication和config对象注入绑定中: 前任: 常规配置 ... grails.serverURL = "https://mycompany.com/" ... application.js-gtpl: //= require_self var serverURL...
:simple-blog:0.3.3 " 安装后,您将有一个控制器可以访问: http://localhost:8080/<your>/blog用户评估员为了使用这个插件,你需要在grails-app/conf/Config.groovy中定义一个返回当前用户的闭包。 例如,
如何为了充分理解用本项目实现的不同案例之间的关系,建议按以下方式使用: 通过更改Config.groovy的选项来试验不同的可用客户端模式域此应用程序中的域尝试广泛使用插件提供的映射选项。 要查找特定映射,请参阅...
可以通过将插件包含在BuildConfig.groovy中来完成此操作,如下所示。 (显然xyz已替换为所需版本的插件。) import grails.util.Environment// in the plugins blockif (Environment.current != Environment....
安装插件后,您必须将以下配置添加到Config.groovy文件中: // Grails-url-shortener shortener { characters = ( ' 0 ' .. ' 9 ' ) + ( ' a ' .. ' h ' ) + ( ' j ' .. ' k ' ) + ( ' m ' .. ' z ' ) + ( ' A ' ...