整合druid连接池

今天主要是想要搭建一个基于连接池mysql连接, 不过用的不是原生态的druid连接方式, 原生的那种配置多数据源说不定还挺方便的

       <dependency>
            <groupId>org.mybatis.spring.boot</groupId>
            <artifactId>mybatis-spring-boot-starter</artifactId>
            <version>1.3.2</version>
        </dependency>
        <!-- mysql -->
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <version>8.0.19</version>
        </dependency>
        <dependency>
            <groupId>com.alibaba</groupId>
            <artifactId>druid-spring-boot-starter</artifactId>
            <version>1.1.17</version>
        </dependency>

server:
  port: 9100
spring:
  cloud:
    gateway:
      enabled: true
      httpclient:
        connect-timeout: 300000

  datasource:
    driver-class-name: com.mysql.cj.jdbc.Driver
    druid:
      initial-size: 5
      max-active: 20
      max-evictable-idle-time-millis: 60000
      max-wait: 60000
      min-evictable-idle-time-millis: 30000
      min-idle: 5
      password: password
      test-on-borrow: false
      test-while-idle: true
      time-between-eviction-runs-millis: 60000
      url: jdbc:mysql://ip:端口/xxx?characterEncoding=UTF-8&autoReconnect=true&zeroDateTimeBehavior=convertToNull&useUnicode=true
      username: root
      validation-query: SELECT 1


  application:
    name: xxxx

mybatis:
  # mapper-locations: classpath:mybatis/mapper/**/*Mapper.xml
  configuration:
    call-setters-on-nulls: true
    map-underscore-to-camel-case: true
    log-impl: org.apache.ibatis.logging.stdout.StdOutImpl

然后就可以正常使用了

©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容