mirror of
https://gitee.com/mybatis-flex/mybatis-flex.git
synced 2025-12-06 16:48:24 +08:00
文档添加 solon 配置相关的内容(补在 spring 配置文档上。现在几乎一样)
This commit is contained in:
parent
9ff17cb494
commit
b9e045b6a8
@ -1,6 +1,6 @@
|
||||
# SpringBoot 配置文件
|
||||
# SpringBoot 或 Solon 配置文件
|
||||
|
||||
SpringBoot 配置文件(`application.yml` 等)主要是用于对 MyBatis 原生以及 MyBatis-Flex 的 `FlexGlobalConfig` 进行配置。
|
||||
SpringBoot 配置文件(`application.yml` 等);Solon 配置文件(`app.yml` 等)。主要是用于对 MyBatis 原生以及 MyBatis-Flex 的 `FlexGlobalConfig` 进行配置。
|
||||
|
||||
示例如下:
|
||||
|
||||
@ -26,7 +26,7 @@ mybatis-flex:
|
||||
- 类型:`Map<String, Map<String, String>>`
|
||||
- 默认值:`null`
|
||||
|
||||
MyBatis-Flex 多数据源配置,参考 [多数据源配置](../core/multi-datasource.md#更多的-spring-yaml-配置支持)。
|
||||
MyBatis-Flex 多数据源配置,参考 [多数据源配置](../core/multi-datasource.md#更多的-yaml-配置支持)。
|
||||
|
||||
### config-location
|
||||
|
||||
@ -203,7 +203,7 @@ mybatis-flex:
|
||||
|
||||
### seata-mode
|
||||
|
||||
- 类型:`com.mybatisflex.spring.boot.MybatisFlexProperties.SeataMode`
|
||||
- 类型:`com.mybatisflex.spring.boot.MybatisFlexProperties.SeataMode`,或者 `com.mybatisflex.solon.MybatisFlexProperties.SeataMode`
|
||||
- 默认值:`AT`
|
||||
|
||||
使用 Seata AT 模式代理数据源。
|
||||
|
||||
@ -18,7 +18,7 @@ mybatis-flex:
|
||||
|
||||
在以上配置中,`ds1` 和 `ds2` 是由用户自定义的,我们可以理解为数据源的名称,或者数据源的 `key`,这个在动态切换数据库中非常有用。
|
||||
|
||||
在无 Spring 框架的场景下,代码如下:
|
||||
在无 Spring 或 Solon 框架的场景下,代码如下:
|
||||
|
||||
```java
|
||||
DataSource dataSource1 = new HikariDataSource();
|
||||
@ -72,7 +72,7 @@ MyBatis-Flex 提供了 4 种方式来配置数据源:
|
||||
- 3、`@UseDataSource("dataSourceName")` 在 Mapper 方法上,添加注解,用于指定使用哪个数据源。
|
||||
- 4、`@Table(dataSource="dataSourceName")` 在 Entity 类上添加注解,该 Entity 的增删改查请求默认使用该数据源。
|
||||
|
||||
> 在 SpringBoot 项目上,`@UseDataSource("dataSourceName")` 也可用于在 Controller 或者 Service 上。若是 Spring 项目(非 SpringBoot),
|
||||
> 在 SpringBoot 或 Solon 项目上,`@UseDataSource("dataSourceName")` 也可用于在 Controller 或者 Service 类上。若是 Spring 项目(非 SpringBoot),
|
||||
> 用户需要参考 `MultiDataSourceAutoConfiguration` 进行配置后才能使用。
|
||||
|
||||
|
||||
@ -123,7 +123,7 @@ public class Account {
|
||||
`DataSourceKey.use()` > `@UseDataSource()在方法上` > `@UseDataSource()在类上` >`@Table(dataSource="...")`
|
||||
:::
|
||||
|
||||
## 更多的 Spring Yaml 配置支持
|
||||
## 更多的 Spring 或 Solon Yaml 配置支持
|
||||
```yaml
|
||||
mybatis-flex:
|
||||
datasource:
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user