Use case analysis of spring MVC mybatis multi data source

The project needs to obtain data from other websites because it is a temporary demand. I didn't expect to need multiple data sources at the beginning of the project

So Baidu searched and found that it only needed to change the ApplicationContext of spring XML file and writing three tool classes can be perfectly implemented

applicationContext. xml

DataSourceContextHolder. java

DataSourceType. Java (set static variables)

Next, this is the key dynamic datasource Java, which inherits the abstract method determinecurrentlookupkey in abstractroutingdatasource, is the core of the route that implements the data source This method is overridden here.

The above is the use example analysis of spring MVC mybatis multi data source introduced by Xiaobian. I hope it will be helpful to you. If you have any questions, please leave me a message and Xiaobian will reply to you in time. Thank you very much for your support for the programming tips website!

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>