baomidou / dynamic-datasource

dynamic datasource for springboot 多数据源 动态数据源 主从分离 读写分离 分布式事务
https://www.kancloud.cn/tracy5546/dynamic-datasource/2264611
Apache License 2.0
4.67k stars 1.19k forks source link

咨询@DS切换数据源,使用spel返回null #205

Closed xiayz closed 4 years ago

xiayz commented 4 years ago

Enviroment

JDK Version(required): 1.8

SpringBoot Version(required): 2.26

dynamic-datasource-spring-boot-starter Version(required):3.1.0

druid Version(optional):

Describe

在Service类上使用DS注解,使用spel表达式,取不到定义的属性值,报错,null。

请看一下,使用方法是否正确。

Expected Result:

Actual Result:

Steps to reproduce

报错,logdb属性值为null

0532 commented 4 years ago

你种写法不对吧

看一下他这个 https://github.com/baomidou/dynamic-datasource-spring-boot-starter/wiki/Dynamic-Analysis-DataSource

ls9527 commented 4 years ago

确实啊,如果是静态属性的话, 你得修改模板解析方式.然后取值方式: #{T(LogDBConfig).logdb}

在20200522这一天应该还没有发布最新版本. 不过可以参考另一个 issues #199

huayanYu commented 4 years ago

近期会发版,支持自己修改模板解析方式

xiayz commented 4 years ago

谢谢各位的回复。