Springboot连接数据库配置
本⽂使⽤druid连接池和mysql作为演⽰,springboot默认使⽤HikariCP连接池。
1、引⼊依赖
<dependency>
<groupId>mysql</groupId>
druid连接池配置详解<artifactId>mysql-connector-java</artifactId>
<version>8.0.26</version>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.12</version>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid</artifactId>
<version>1.2.8</version>
</dependency>
<dependency>
<groupId&batis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
<version>2.1.3</version>
</dependency>
2、配置l⽂件
spring:
datasource:
type: com.alibaba.druid.pool.DruidDataSource
driver-class-name: sql.cj.jdbc.Driver
url: jdbc:mysql://localhost:3306/mybatis?serverTimeZone=UTC&useUnicode=true&characterEncoding=UTF-8&useSSL=false username: root
password: zhongxiaoting
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论