SpringBoot整合Druid数据源

数据源对象都是SpringBoot默认的数据源对象,下面我们手工控制指定Druid数据源对象。

在没有指定数据源时,我们的配置如下:

spring:
  application:
    name: demo-springboot-configuration
  datasource:
    driver-class-name: com.mysql.jdbc.Driver
    url: dbc:mysql://localhost:3306/demo?characterEncoding=utf-8
    username: root
    password: root

此时虽然没有指定数据源,但是根据SpringBoot的内置数据源来看,选了一个它认为最好的数据源对象,这就是HiKari.通过启动日志我们可以查看到它的身影。

上述信息中每一行都有HiKari的身影,如果需要更换数据源,其实只需要两步即可。

1、导入对应的依赖



    com.alibaba
    druid
    1.2.24

2、配置使用指定的数据源类型

你可能感兴趣的:(SpringBoot,JAVA,spring,boot,后端,java)