Grails4 开发(dev)、测试(test)、生产(prod) 环境配置快速切换

目录结构

1、application.yml

---
grails:
    profile: rest-api
    cors:
        enabled: true
    codegen:
        defaultPackage: qmsv2
    databinding:
        dateFormats:
            - 'dd/MM/yyyy'
            - 'dd/MM/yyyy HH:mm:ss'
            - 'yyyy-MM-dd HH:mm:ss.S'
            - "yyyy-MM-dd'T'hh:mm:ss'Z'"
            - "yyyy-MM-dd HH:mm:ss.S z"
            - "yyyy-MM-dd'T'HH:mm:ssX"
            - "yyyy-MM-dd HH:mm:ss"
            - "yyyy-MM-dd HH:mm"
    gorm:
        autowire: true
        reactor:
            # Whether to translate GORM events into Reactor events
            # Disabled by default for performance reasons
            events: false
    redis:
        poolConfig:
            maxIdle: 10
            doesnotexist: true
        timeout: 100000   #default in milliseconds
        useSSL: false   #or true to use SSL
        port: 6379
        host: localhost
        database: 10
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'
management:
    endpoints:
        enabled-by-default: false

---
grails:
    mime:
        disable:
            accept:
                header:
                    userAgents:
                        - Gecko
                        - WebKit
                        - Presto
                        - Trident
        types:
            json:
              - application/json
              - text/json   
            hal:
              - application/hal+json
              - application/hal+xml  
            xml:
              - text/xml
              - application/xml                                 
            atom: application/atom+xml
            css: text/css
            csv: text/csv
            js: text/javascript
            rss: application/rss+xml
            text: text/plain
            all: '*/*'            
    urlmapping:
        cache:
            maxsize: 1000
    controllers:
        defaultScope: singleton
    converters:
        encoding: UTF-8
---
spring:
    profiles:
        include: dev

2、application-dev.yml


---
hibernate:
    cache:
        queries: true
        use_second_level_cache: true
        use_query_cache: true
        region.factory_class: org.hibernate.cache.ehcache.internal.EhcacheRegionFactory
    naming_strategy: middol.base.MiddolCustomNamingStrategy
dataSource:
    pooled: true
    jmxExport: true
    dialect: org.hibernate.dialect.MySQL5InnoDBDialect
    type: com.zaxxer.hikari.HikariDataSource
    driverClassName: '${jdbc.driver}'
    username: '${jdbc.username}'
    password: '${jdbc.password}'

environments:
    development:
        dataSource:
            #            logSql: true
            dbCreate: '${jdbc.dbCreate}'
            url: '${jdbc.url}'
    test:
        dataSource:
            dbCreate: update
            url: jdbc:h2:mem:testDb;MVCC=TRUE;LOCK_TIMEOUT=10000;DB_CLOSE_ON_EXIT=FALSE
    production:
        dataSource:
            dbCreate: none
            url: jdbc:h2:./prodDb;MVCC=TRUE;LOCK_TIMEOUT=10000;DB_CLOSE_ON_EXIT=FALSE
            properties:
                jmxEnabled: true
                initialSize: 5
                maxActive: 50
                minIdle: 5
                maxIdle: 25
                maxWait: 10000
                maxAge: 10 * 60000
                timeBetweenEvictionRunsMillis: 5000
                minEvictableIdleTimeMillis: 60000
                validationQuery: "SELECT 1"
                validationQueryTimeout: 3
                validationInterval: 15000
                testOnBorrow: true
                testWhileIdle: true
                testOnReturn: false
                jdbcInterceptors: "ConnectionState;StatementCache(max=200)"
                defaultTransactionIsolation: java.sql.Connection.TRANSACTION_READ_COMMITTED

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值