91超碰碰碰碰久久久久久综合_超碰av人澡人澡人澡人澡人掠_国产黄大片在线观看画质优化_txt小说免费全本

溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

Grails3怎么更換連接池

發布時間:2021-11-16 14:15:13 來源:億速云 閱讀:156 作者:iii 欄目:大數據

這篇文章主要介紹“Grails3怎么更換連接池”,在日常操作中,相信很多人在Grails3怎么更換連接池問題上存在疑惑,小編查閱了各式資料,整理出簡單好用的操作方法,希望對大家解答”Grails3怎么更換連接池”的疑惑有所幫助!接下來,請跟著小編一起來學習吧!

Grails3默認數據庫連接池為tomcat-jdbc pool,性能較druidHikariCP差太多,所以想換成其他連接池

  • 由于默認使用的是tomcat-jdbc連接池,需要去掉依賴

//    runtime "com.h3database:h3"
//    runtime "org.apache.tomcat:tomcat-jdbc"

// 添加阿里巴巴druid連接池
compile group: 'com.alibaba', name: 'druid', version: '1.1.18'
compile 'mysql:mysql-connector-java:5.1.40'
  • grails-app/conf/applicaiton.yml配置也要注釋掉默認的連接池

dataSource:
#    pooled: true
    jmxExport: true
    driverClassName: com.mysql.jdbc.Driver
    username: root
    password: root
    dialect: org.hibernate.dialect.MySQL5InnoDBDialect
    url: jdbc:mysql://localhost:3306/g3?useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull&useSSL=false
    # 為了兼容grails,讓Hibernate自動建表,所以在dataSource下增加連接池相關的配置
    druid:
        minIdle: 1
        maxActive: 40
        maxWait: 60000
        initialSize: 20
        testWhileIdle: true
        testOnBorrow: false
        testOnReturn: false
        removeAbandoned: true
        filters: stat,wall,slf4j
        validationQuery: select 'x'
        useGlobalDataSourceStat: true
        poolPreparedStatements: true
        minEvictableIdleTimeMillis: 300000
        timeBetweenEvictionRunsMillis: 60000
        connectionProperties: clientEncoding=UTF-8
        maxPoolPreparedStatementPerConnectionSize: 20
environments:
    development:
        dataSource:
            dbCreate: create-drop
            url: jdbc:mysql://localhost:3306/g3?useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull&useSSL=false
    test:
        dataSource:
            dbCreate: update
            url: jdbc:mysql://localhost:3306/g3?useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull&useSSL=false
    production:
        dataSource:
            dbCreate: update
            url: jdbc:mysql://localhost:3306/g3?useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull&useSSL=false
server:
  port: 8081  # TRANSACTION_READ_COMMITTED
  • grails-app/conf/spring/resources.groovy配置

// Place your Spring DSL code here
beans = {

    // 監控管理頁面配置(管理用戶名、密碼)
    druidConsoleServlet(org.springframework.boot.web.servlet.ServletRegistrationBean) {
        servlet = bean(com.alibaba.druid.support.http.StatViewServlet)
        urlMappings = ["/druid/*"]
//        urlMappings = ["*.js","*.gif","*.jpg","*.png","*.css","*.ico","/druid/*"]
        initParameters = [
                "loginUsername": "root",
                "loginPassword": "123456",
                "allow": "127.0.0.1",
                "deny": ""
        ]
//        loadOnStartup = 2
    }


    // alibaba druid配置
    dataSource(com.alibaba.druid.pool.DruidDataSource) { bean ->
        bean.initMethod = 'init'
        bean.destroyMethod = 'close'
        driverClassName = grailsApplication.config.dataSource.driverClassName
        url = grailsApplication.config.dataSource.url
        username = grailsApplication.config.dataSource.username
        password = grailsApplication.config.dataSource.password
        initialSize = grailsApplication.config.dataSource.druid.initialSize
        minIdle = grailsApplication.config.dataSource.druid.minIdle
        maxActive = grailsApplication.config.dataSource.druid.maxActive
        maxWait = grailsApplication.config.dataSource.druid.maxWait
        timeBetweenEvictionRunsMillis = grailsApplication.config.dataSource.druid.timeBetweenEvictionRunsMillis
        minEvictableIdleTimeMillis = grailsApplication.config.dataSource.druid.minEvictableIdleTimeMillis
        validationQuery = grailsApplication.config.dataSource.druid.validationQuery
        removeAbandoned = grailsApplication.config.dataSource.druid.removeAbandoned
        testWhileIdle = grailsApplication.config.dataSource.druid.testWhileIdle
        connectionProperties = grailsApplication.config.dataSource.druid.connectionProperties
        testOnBorrow = grailsApplication.config.dataSource.druid.testOnBorrow
        poolPreparedStatements = grailsApplication.config.dataSource.druid.poolPreparedStatements
        testOnReturn = grailsApplication.config.dataSource.druid.testOnReturn
        useGlobalDataSourceStat = grailsApplication.config.dataSource.druid.useGlobalDataSourceStat
        maxPoolPreparedStatementPerConnectionSize = grailsApplication.config.dataSource.druid.maxPoolPreparedStatementPerConnectionSize
        filters = grailsApplication.config.dataSource.druid.filters
    }
}
  • grails-app/conf/logback.groovy添加日志配置

// 日志采集
logger('com.alibaba', DEBUG, ['STDOUT'], false)
  • 啟動項目,出現日志

2019-07-03 03:15:06.691  WARN --- [           main] com.alibaba.druid.pool.DruidDataSource   : removeAbandoned is true, not use in productiion.
2019-07-03 03:15:07.078  INFO --- [           main] com.alibaba.druid.pool.DruidDataSource   : {dataSource-1} inited
Grails application running at http://localhost:8081 in environment: development
  • web監控地址

http://127.0.0.1:8081/druid/index.html

到此,關于“Grails3怎么更換連接池”的學習就結束了,希望能夠解決大家的疑惑。理論與實踐的搭配能更好的幫助大家學習,快去試試吧!若想繼續學習更多相關知識,請繼續關注億速云網站,小編會繼續努力為大家帶來更多實用的文章!

向AI問一下細節

免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

AI

哈密市| 屯门区| 石楼县| 尚志市| 六枝特区| 嘉兴市| 汝州市| 泗阳县| 繁昌县| 岢岚县| 武功县| 东乡县| 马公市| 南雄市| 双辽市| 岳阳市| 永登县| 六枝特区| 迁安市| 湖南省| 临夏县| 霍林郭勒市| 奉化市| 莲花县| 新邵县| 临朐县| 西乡县| 明光市| 大冶市| 富民县| 枝江市| 叶城县| 澄迈县| 南和县| 泸水县| 临沭县| 隆化县| 宁南县| 克山县| 金川县| 铅山县|