正式開始研究springboot的數據庫集成
*******************第一個概論druid*******************
?Druid是一個數據庫連接池,
添加依賴:
<dependency><groupId>com.alibaba</groupId><artifactId>druid-spring-boot-starter</artifactId><version>1.1.10</version></dependency>
Springboot注解,添加配置:
spring:datasource:# 配置數據源driver-class-name: com.mysql.jdbc.Driver# 使用druid連接池type: com.alibaba.druid.pool.DruidDataSourceurl: jdbc:mysql://127.0.0.1:3306/test?characterEncoding=utf-8&autoReconnect=true&failOverReadOnly=false&useSSL=trueusername: rootpassword: sadruid:# 通過connectProperties屬性來打開mergeSql功能;慢SQL記錄connection-properties: druid.stat.mergeSql=true;druid.stat.slowSqlMillis=5000# 初始化大小,最小,最大initial-size: 5max-active: 50min-idle: 5# 配置獲取連接等待超時時間max-wait: 60000# 打開PSCache,并且指定每個連接上PSCache的大小pool-prepared-statements: truemax-pool-prepared-statement-per-connection-size: 20validation-query: SELECT 'x'validation-query-timeout: 60000test-on-borrow: truetest-on-return: truetest-while-idle: true# 配置間隔多久才進行一次檢測,檢測需要關閉的空閑連接,單位是毫秒time-between-eviction-runs-millis: 60000min-evictable-idle-time-millis: 300000log-abandoned: trueremove-abandoned: trueremove-abandoned-timeout: 1800filters: stat,wallweb-stat-filter:enabled: trueurl-pattern: /*exclusions: '*.js,*.gif,*.jpg,*.bmp,*.png,*.css,*.ico,/druid/*'# 管理后臺的url和登錄賬號密碼stat-view-servlet:enabled: trueurl-pattern: /druid/*reset-enable: truelogin-username: adminlogin-password: 123456# 配置StatFilterfilter:stat:db-type: mysqllog-slow-sql: trueslow-sql-millis: 2000# 配置WallFilterwall:db-type: mysqlenabled: trueconfig:delete-allow: truedrop-table-allow: falsemulti-statement-allow: truedelete-where-alway-true-check: truedelete-where-none-check: true# 合并多個DruidDataSource的監控數據use-global-data-source-stat: true
?
?*******************第二個Mybatis*******************
?
版权声明:本站所有资料均为网友推荐收集整理而来,仅供学习和研究交流使用。
工作时间:8:00-18:00
客服电话
电子邮件
admin@qq.com
扫码二维码
获取最新动态