88 lines
2.4 KiB
Markdown
88 lines
2.4 KiB
Markdown
# Springboot3和JDK17的基础脚手架 - 数据库分支
|
||
|
||
|
||
|
||
## 基础依赖
|
||
- MySQL
|
||
- MyBatis-Plus 3.5.15 这个版本是SpringBoot3支持的最高版本
|
||
- jsqlparser 在MyBatis-Plus 3.5.9以后的版本,插件部分开始修改为可选依赖,所以这里手动增加。
|
||
|
||
> 引入 MyBatis-Plus 之后请不要再次引入 MyBatis 以及 mybatis-spring-boot-starter和MyBatis-Spring,以避免因版本差异导致的问题。
|
||
|
||
```xml
|
||
<dependency>
|
||
<groupId>com.mysql</groupId>
|
||
<artifactId>mysql-connector-j</artifactId>
|
||
<scope>runtime</scope>
|
||
</dependency>
|
||
|
||
<dependency>
|
||
<groupId>com.baomidou</groupId>
|
||
<artifactId>mybatis-plus-spring-boot3-starter</artifactId>
|
||
<version>3.5.15</version>
|
||
</dependency>
|
||
|
||
<dependency>
|
||
<groupId>com.baomidou</groupId>
|
||
<artifactId>mybatis-plus-jsqlparser</artifactId>
|
||
<version>3.5.14</version>
|
||
<scope>compile</scope>
|
||
</dependency>
|
||
```
|
||
|
||
|
||
|
||
## Druid数据源配置详解
|
||
- [官方WIKI](https://github.com/alibaba/druid/wiki/%E9%A6%96%E9%A1%B5)
|
||
|
||
### Druid多数据源说明
|
||
添加配置
|
||
```properties
|
||
spring.datasource.url=
|
||
spring.datasource.username=
|
||
spring.datasource.password=
|
||
|
||
# Druid 数据源配置,继承spring.datasource.* 配置,相同则覆盖
|
||
spring.datasource.druid.initial-size=5
|
||
spring.datasource.druid.max-active=5
|
||
|
||
# Druid 数据源 1 配置,继承spring.datasource.druid.* 配置,相同则覆盖
|
||
spring.datasource.druid.one.max-active=10
|
||
spring.datasource.druid.one.max-wait=10000
|
||
|
||
|
||
# Druid 数据源 2 配置,继承spring.datasource.druid.* 配置,相同则覆盖
|
||
|
||
spring.datasource.druid.two.max-active=20
|
||
spring.datasource.druid.two.max-wait=20000
|
||
|
||
```
|
||
|
||
# Druid 数据源配置,继承spring.datasource.* 配置,相同则覆盖
|
||
|
||
```properties
|
||
spring.datasource.druid.initial-size=5
|
||
spring.datasource.druid.max-active=5
|
||
```
|
||
|
||
# Druid 数据源 1 配置,继承spring.datasource.druid.* 配置,相同则覆盖
|
||
```properties
|
||
|
||
|
||
spring.datasource.druid.one.max-active=10
|
||
spring.datasource.druid.one.max-wait=10000
|
||
```
|
||
|
||
# Druid 数据源 2 配置,继承spring.datasource.druid.* 配置,相同则覆盖
|
||
```properties
|
||
spring.datasource.druid.two.max-active=20
|
||
spring.datasource.druid.two.max-wait=20000
|
||
```
|
||
|
||
强烈注意:**Spring Boot 2.X** 版本不再支持配置继承,多数据源的话每个数据源的所有配置都需要单独配置,否则配置不会生效
|
||
|
||
|
||
|
||
## MyBatis-Plus配置详解
|
||
- [官网文档](https://baomidou.com/introduce/)
|