What if the springboot multi-data source configuration does not take effect
This article mainly introduces the springboot multi-data source configuration does not take effect how to do, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let the editor take you to understand it.
According to the problem of multiple data source switching encountered when synchronizing data, according to the pit encountered when the source configuration does not take effect, configure the configuration that the data source is not loaded when the yml file is found to be started. * * spring:datasource:db1:driver-class-name:xxxxxxxurl:jdbc:xxxxxxxusername:rootpassword:111111db2:driver-class-name:xxxxxxurl:xxxxxxusername:rootpassword:111111
Wait, wait, wait.
Every configuration has been checked, there is no mistake, and it has been right several times. I tossed about for a long time.
Solution
The format in the yml configuration file is not aligned. The db1 db2 db3 should be on the same column.
The compiler does not have any hints and will not be loaded with an extra space or misalignment.
Trample SpringBoot configuration multiple data sources, cyclic reference problem
Recently, using SpringBoot to configure AOP dynamic data source, which is achieved by inheriting the class AbstractRoutingDataSource, reported an error when using it, as follows
It is probably that dynamicDataSource depends on dataSourceScxys, dataSourceScxys depends on DataSourceInitializerInvoker, and DataSourceInitializerInvoker depends on dynamicDataSource, resulting in a circular reference. When Spring initializes bean, you don't know which one to initialize first.
Solution.
Exclude the automatic configuration class of springboot when it starts, as follows
Thank you for reading this article carefully. I hope the article "what if the springboot multi-data source configuration does not take effect" shared by the editor will be helpful to you. At the same time, I also hope that you will support us and pay attention to the industry information channel. More related knowledge is waiting for you to learn!