Closed xiayz closed 4 years ago
JDK Version(required): 1.8
SpringBoot Version(required): 2.26
dynamic-datasource-spring-boot-starter Version(required):3.1.0
druid Version(optional):
在Service类上使用DS注解,使用spel表达式,取不到定义的属性值,报错,null。
请看一下,使用方法是否正确。
Expected Result:
Actual Result:
Step 1 在application.yml配置自定义属性:logdb: db_log
Step 2 启动初始化配置类:LogDBConfig
Step 3 @DS("#LogDBConfig.logdb") @Service public class SysLogininforServiceImpl {}
报错,logdb属性值为null
你种写法不对吧
看一下他这个 https://github.com/baomidou/dynamic-datasource-spring-boot-starter/wiki/Dynamic-Analysis-DataSource
确实啊,如果是静态属性的话, 你得修改模板解析方式.然后取值方式: #{T(LogDBConfig).logdb}
在20200522这一天应该还没有发布最新版本. 不过可以参考另一个 issues #199
近期会发版,支持自己修改模板解析方式
谢谢各位的回复。
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
Step 1 在application.yml配置自定义属性:logdb: db_log
Step 2 启动初始化配置类:LogDBConfig
Step 3 @DS("#LogDBConfig.logdb") @Service public class SysLogininforServiceImpl {}
报错,logdb属性值为null