update 多数据源切换标注过期 3.6.0 移除 推荐使用原生注解
This commit is contained in:
parent
be13e3494a
commit
a9488ba3c9
@ -95,6 +95,13 @@
|
||||
<groupId>com.baomidou</groupId>
|
||||
<artifactId>mybatis-plus-extension</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- dynamic-datasource 多数据源-->
|
||||
<dependency>
|
||||
<groupId>com.baomidou</groupId>
|
||||
<artifactId>dynamic-datasource-spring-boot-starter</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>cn.hutool</groupId>
|
||||
<artifactId>hutool-all</artifactId>
|
||||
|
@ -10,11 +10,13 @@ import java.lang.annotation.*;
|
||||
* 优先级:先方法,后类,如果方法覆盖了类上的数据源类型,以方法的为准,否则以类上的为准
|
||||
*
|
||||
* @author ruoyi
|
||||
* @deprecated 3.6.0 移除 使用原生注解处理 方法更全 {@link com.baomidou.dynamic.datasource.annotation.DS}
|
||||
*/
|
||||
@Target({ElementType.METHOD, ElementType.TYPE})
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Documented
|
||||
@Inherited
|
||||
@Deprecated
|
||||
public @interface DataSource {
|
||||
/**
|
||||
* 切换数据源名称
|
||||
|
@ -7,8 +7,10 @@ import lombok.Getter;
|
||||
* 数据源
|
||||
*
|
||||
* @author Lion Li
|
||||
* @deprecated 3.6.0 移除
|
||||
*/
|
||||
@AllArgsConstructor
|
||||
@Deprecated
|
||||
public enum DataSourceType {
|
||||
/**
|
||||
* 主库
|
||||
|
@ -23,7 +23,7 @@ import java.util.Map;
|
||||
* @author Lion Li
|
||||
* @date 2021-07-26
|
||||
*/
|
||||
//@DataSource(DataSourceType.SLAVE) // 切换从库查询
|
||||
// @DS("slave") // 切换从库查询
|
||||
@Service
|
||||
public class TestTreeServiceImpl extends ServicePlusImpl<TestTreeMapper, TestTree, TestTreeVo> implements ITestTreeService {
|
||||
|
||||
@ -32,8 +32,8 @@ public class TestTreeServiceImpl extends ServicePlusImpl<TestTreeMapper, TestTre
|
||||
return getVoById(id);
|
||||
}
|
||||
|
||||
// @DataSource(DataSourceType.SLAVE) // 切换从库查询
|
||||
@DataScope(isUser = true)
|
||||
// @DS("slave") // 切换从库查询
|
||||
@DataScope(isUser = true)
|
||||
@Override
|
||||
public List<TestTreeVo> queryList(TestTreeBo bo) {
|
||||
LambdaQueryWrapper<TestTree> lqw = buildQueryWrapper(bo);
|
||||
|
@ -46,11 +46,6 @@
|
||||
<artifactId>druid-spring-boot-starter</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- dynamic-datasource 多数据源-->
|
||||
<dependency>
|
||||
<groupId>com.baomidou</groupId>
|
||||
<artifactId>dynamic-datasource-spring-boot-starter</artifactId>
|
||||
</dependency>
|
||||
<!-- sql性能分析插件 -->
|
||||
<dependency>
|
||||
<groupId>p6spy</groupId>
|
||||
|
@ -18,10 +18,12 @@ import java.util.Objects;
|
||||
* 多数据源处理
|
||||
*
|
||||
* @author Lion Li
|
||||
* @deprecated 3.6.0 移除 使用原生方法处理 功能更全
|
||||
*/
|
||||
@Aspect
|
||||
@Order(-500)
|
||||
@Component
|
||||
@Deprecated
|
||||
public class DataSourceAspect {
|
||||
|
||||
@Pointcut("@annotation(com.ruoyi.common.annotation.DataSource)"
|
||||
|
@ -53,7 +53,7 @@ public class SysConfigServiceImpl extends ServicePlusImpl<SysConfigMapper, SysCo
|
||||
* @return 参数配置信息
|
||||
*/
|
||||
@Override
|
||||
@DataSource(DataSourceType.MASTER)
|
||||
@DS("master")
|
||||
public SysConfig selectConfigById(Long configId) {
|
||||
return baseMapper.selectById(configId);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user