update 多数据源切换标注过期 3.6.0 移除 推荐使用原生注解

This commit is contained in:
疯狂的狮子li 2021-12-08 13:50:27 +08:00
parent be13e3494a
commit a9488ba3c9
7 changed files with 17 additions and 9 deletions

View File

@ -95,6 +95,13 @@
<groupId>com.baomidou</groupId> <groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-extension</artifactId> <artifactId>mybatis-plus-extension</artifactId>
</dependency> </dependency>
<!-- dynamic-datasource 多数据源-->
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>dynamic-datasource-spring-boot-starter</artifactId>
</dependency>
<dependency> <dependency>
<groupId>cn.hutool</groupId> <groupId>cn.hutool</groupId>
<artifactId>hutool-all</artifactId> <artifactId>hutool-all</artifactId>

View File

@ -10,11 +10,13 @@ import java.lang.annotation.*;
* 优先级先方法后类如果方法覆盖了类上的数据源类型以方法的为准否则以类上的为准 * 优先级先方法后类如果方法覆盖了类上的数据源类型以方法的为准否则以类上的为准
* *
* @author ruoyi * @author ruoyi
* @deprecated 3.6.0 移除 使用原生注解处理 方法更全 {@link com.baomidou.dynamic.datasource.annotation.DS}
*/ */
@Target({ElementType.METHOD, ElementType.TYPE}) @Target({ElementType.METHOD, ElementType.TYPE})
@Retention(RetentionPolicy.RUNTIME) @Retention(RetentionPolicy.RUNTIME)
@Documented @Documented
@Inherited @Inherited
@Deprecated
public @interface DataSource { public @interface DataSource {
/** /**
* 切换数据源名称 * 切换数据源名称

View File

@ -7,8 +7,10 @@ import lombok.Getter;
* 数据源 * 数据源
* *
* @author Lion Li * @author Lion Li
* @deprecated 3.6.0 移除
*/ */
@AllArgsConstructor @AllArgsConstructor
@Deprecated
public enum DataSourceType { public enum DataSourceType {
/** /**
* 主库 * 主库

View File

@ -23,7 +23,7 @@ import java.util.Map;
* @author Lion Li * @author Lion Li
* @date 2021-07-26 * @date 2021-07-26
*/ */
//@DataSource(DataSourceType.SLAVE) // 切换从库查询 // @DS("slave") // 切换从库查询
@Service @Service
public class TestTreeServiceImpl extends ServicePlusImpl<TestTreeMapper, TestTree, TestTreeVo> implements ITestTreeService { public class TestTreeServiceImpl extends ServicePlusImpl<TestTreeMapper, TestTree, TestTreeVo> implements ITestTreeService {
@ -32,7 +32,7 @@ public class TestTreeServiceImpl extends ServicePlusImpl<TestTreeMapper, TestTre
return getVoById(id); return getVoById(id);
} }
// @DataSource(DataSourceType.SLAVE) // 切换从库查询 // @DS("slave") // 切换从库查询
@DataScope(isUser = true) @DataScope(isUser = true)
@Override @Override
public List<TestTreeVo> queryList(TestTreeBo bo) { public List<TestTreeVo> queryList(TestTreeBo bo) {

View File

@ -46,11 +46,6 @@
<artifactId>druid-spring-boot-starter</artifactId> <artifactId>druid-spring-boot-starter</artifactId>
</dependency> </dependency>
<!-- dynamic-datasource 多数据源-->
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>dynamic-datasource-spring-boot-starter</artifactId>
</dependency>
<!-- sql性能分析插件 --> <!-- sql性能分析插件 -->
<dependency> <dependency>
<groupId>p6spy</groupId> <groupId>p6spy</groupId>

View File

@ -18,10 +18,12 @@ import java.util.Objects;
* 多数据源处理 * 多数据源处理
* *
* @author Lion Li * @author Lion Li
* @deprecated 3.6.0 移除 使用原生方法处理 功能更全
*/ */
@Aspect @Aspect
@Order(-500) @Order(-500)
@Component @Component
@Deprecated
public class DataSourceAspect { public class DataSourceAspect {
@Pointcut("@annotation(com.ruoyi.common.annotation.DataSource)" @Pointcut("@annotation(com.ruoyi.common.annotation.DataSource)"

View File

@ -53,7 +53,7 @@ public class SysConfigServiceImpl extends ServicePlusImpl<SysConfigMapper, SysCo
* @return 参数配置信息 * @return 参数配置信息
*/ */
@Override @Override
@DataSource(DataSourceType.MASTER) @DS("master")
public SysConfig selectConfigById(Long configId) { public SysConfig selectConfigById(Long configId) {
return baseMapper.selectById(configId); return baseMapper.selectById(configId);
} }