Read-write separation of multiple data sources
To achieve the separation of reading and writing of multiple data sources on the existing system that has been launched, avoid modifying the existing code, using jdbc, hibernate and mybatis, after a round of tossing, the basic idea is to write methods to inherit spring's AbstractRoutingDataSource class, rewrite its The determineCurrentLookupKey method uses aop to switch the data source. In the various debug and determineCurrentLookupKey methods, the get data source is executed before the set data source of aop. The sessionFactory has already been set, and the data source cannot be switched at all. It seems that you can only define the corresponding read-write sessionFactory, and then write the corresponding sessionFactory to get the session when using it, so as to realize the separation of read-write and read-write. Can not achieve dynamic read-write separation
Guess you like
Origin http://10.200.1.11:23101/article/api/json?id=327039726&siteId=291194637
Recommended
Ranking