來架個網站吧
Grails
昨天本來想要一口氣講完,但是發現篇幅好像有點長,所以決定切兩部份。
---
grails:
profile: web
codegen:
defaultPackage: ironman.dict
gorm:
reactor:
# Whether to translate GORM events into Reactor events
# Disabled by default for performance reasons
events: false
info:
app:
name: '@info.app.name@'
version: '@info.app.version@'
grailsVersion: '@info.app.grailsVersion@'
spring:
jmx:
unique-names: true
main:
banner-mode: "off"
groovy:
template:
check-template-location: false
devtools:
restart:
additional-exclude:
- '*.gsp'
- '**/*.gsp'
- '*.gson'
- '**/*.gson'
- 'logback.groovy'
- '*.properties'
environments:
development:
management:
endpoints:
enabled-by-default: true
web:
base-path: '/actuator'
exposure:
include: '*'
production:
management:
endpoints:
enabled-by-default: false
---
grails:
mime:
disable:
accept:
header:
userAgents:
- Gecko
- WebKit
- Presto
- Trident
types:
all: '*/*'
atom: application/atom+xml
css: text/css
csv: text/csv
form: application/x-www-form-urlencoded
html:
- text/html
- application/xhtml+xml
js: text/javascript
json:
- application/json
- text/json
multipartForm: multipart/form-data
pdf: application/pdf
rss: application/rss+xml
text: text/plain
hal:
- application/hal+json
- application/hal+xml
xml:
- text/xml
- application/xml
urlmapping:
cache:
maxsize: 1000
controllers:
defaultScope: singleton
converters:
encoding: UTF-8
views:
default:
codec: html
gsp:
encoding: UTF-8
htmlcodec: xml
codecs:
expression: html
scriptlet: html
taglib: none
staticparts: none
---
hibernate:
cache:
queries: false
use_second_level_cache: false
use_query_cache: false
dataSource:
pooled: true
jmxExport: true
driverClassName: org.postgresql.Driver
dialect: org.hibernate.dialect.PostgreSQLDialect
type: com.zaxxer.hikari.HikariDataSource
username: dict_ap
password: 'LF2.net'
logSql: false
formatSql: true
environments:
development:
dataSource:
dbCreate: none
url: jdbc:postgresql://127.0.0.1:5432/ironman_dict_db
test:
dataSource:
dbCreate: none
url: jdbc:postgresql://127.0.0.1:5432/ironman_dict_db
production:
dataSource:
dbCreate: none
url: jdbc:postgresql://127.0.0.1:5432/ironman_dict_db
properties:
jmxEnabled: true
initialSize: 5
maxActive: 50
minIdle: 5
maxIdle: 25
maxWait: 10000
maxAge: 600000
timeBetweenEvictionRunsMillis: 5000
minEvictableIdleTimeMillis: 60000
validationQuery: SELECT 1
validationQueryTimeout: 3
validationInterval: 15000
testOnBorrow: true
testWhileIdle: true
testOnReturn: false
jdbcInterceptors: ConnectionState
defaultTransactionIsolation: 2 # TRANSACTION_READ_COMMITTED
grails-app/conf/application.yml
主要是專案的參數文件配置。
在 grails 框架中有三個預設環境,方便在不同環境中切換:
在 development
因為有配置 spring-boot-devtools
,所以在更動程式原始碼時,會啟用熱部屬。
另外如果有第四種以上的環境需要特別部屬,可以自行命名,範例如下:
...
environments:
test:
dataSource:
dbCreate: none
url: jdbc:postgresql://127.0.0.1:5432/ironman_dict_db
example:
dataSource:
dbCreate: none
url: jdbc:postgresql://127.0.0.1:5432/ironman_dict_db
...
在執行,時需要加參數指定環境: -Dgrails.env
-Dgrails.env=example
grails log 預設是 grails-app/conf/logback.xml
,有需求可以另外新增。以下是針對不同環境處理的文件:
相對應的文件描述如下
...
environments:
development:
logging:
config: grails-app/conf/logback-development.xml
test:
logging:
config: "${catalina.base}/webapps/ironman-dict/WEB-INF/classes/logback-test.xml"
...
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<conversionRule conversionWord="clr" converterClass="org.springframework.boot.logging.logback.ColorConverter" />
<conversionRule conversionWord="wex" converterClass="org.springframework.boot.logging.logback.WhitespaceThrowableProxyConverter" />
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<charset>UTF-8</charset>
<pattern>%clr(%d{yyyy-MM-dd HH:mm:ss.SSS}){faint} %clr(%5p) %clr(---){faint} %clr([%15.15t]){faint} %clr(%-40.40logger{39}){cyan} %clr(:){faint} %m%n%wex</pattern>
</encoder>
</appender>
<root level="error">
<appender-ref ref="STDOUT" />
</root>
</configuration>
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<conversionRule conversionWord="clr" converterClass="org.springframework.boot.logging.logback.ColorConverter" />
<conversionRule conversionWord="wex" converterClass="org.springframework.boot.logging.logback.WhitespaceThrowableProxyConverter" />
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<charset>UTF-8</charset>
<pattern>%clr(%d{yyyy-MM-dd HH:mm:ss.SSS}){faint} %clr(%5p) %clr(---){faint} %clr([%15.15t]){faint} %clr(%-40.40logger{39}){cyan} %clr(:){faint} %m%n%wex</pattern>
</encoder>
</appender>
<root level="info">
<appender-ref ref="STDOUT" />
</root>
</configuration>