Closed ldcsaa closed 4 months ago
我觉得应该让他改。
我觉得应该让他改。
你们可否沟通一下~
搞了2天,发现这个坑麻了
我的druid版本是1.1.22 , dynamic 版本是3.2.0 下面是我的yaml配置
spring:
autoconfigure:
exclude: com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceAutoConfigure
datasource:
dynamic:
primary: test1
datasource:
test1:
url: jdbc:mysql://192.168.1.1:5/test1
username: root
password: root
test2:
url: jdbc:mysql://192.168.1.1:5/test2
username: root
password: root
当我启动时,会抛出如下错误
***************************
APPLICATION FAILED TO START
***************************
Description:
Failed to configure a DataSource: 'url' attribute is not specified and no embedded datasource could be configured.
Reason: Failed to determine suitable jdbc url
Action:
Consider the following:
If you want an embedded database (H2, HSQL or Derby), please put it on the classpath.
If you have database settings to be loaded from a particular profile you may need to activate it (the profiles test are currently active).
Disconnected from the target VM, address: '127.0.0.1:14021', transport: 'socket'
Process finished with exit code 1
我将dynamic 的版本降到了2.5.6,再次启动可以正常启动,我不知道跟这个话题有没有关系,但是我想知道为什么会导致出现这个情况,感谢
就是一楼说的原因啊,druid版本改成1.2.21也行
启动类加个注解也可以暂时解决
@SpringBootApplication(exclude = DruidDataSourceAutoConfigure.class)
问题一样,能否迭代?
问题一样,能否迭代?
@Umenezumi 联系druid哦。 我这边不会更改
问题一样,能否迭代?
@Umenezumi 联系 druid 哦。 我这边不会更改
看了下 druid 那边,确实不需要您修改,他们会在下一个版本解决这个问题,劳烦您到时更新 Readme ,避免大家使用 1.2.22 版本
duird 1.2.22 之前的版本,DruidDataSourceAutoConfigure 定义了 DataSource Bean,该Bean定义会被 dynamic-datasource 的 DataSource Bean覆盖,所以没有问题。
但 duird 1.2.22 的 DruidDataSourceAutoConfigure 把 Bean 类型改为了 DruidDataSourceWrapper,dynamic-datasource 不能覆盖这个Bean定义。所以,由于没有相应的druid配置,导致加载 DruidDataSourceWrapper Bean 失败。