這篇文章給大家介紹在springboot中使用mybatis如何實現(xiàn)多數(shù)據(jù)源,內(nèi)容非常詳細(xì),感興趣的小伙伴們可以參考借鑒,希望對大家能有所幫助。
說起多數(shù)據(jù)源,一般都來解決那些問題呢,主從模式或者業(yè)務(wù)比較復(fù)雜需要連接不同的分庫來支持業(yè)務(wù)。我們項目是后者的模式,網(wǎng)上找了很多,大都是根據(jù)jpa來做多數(shù)據(jù)源解決方案,要不就是老的spring多數(shù)據(jù)源解決方案,還有的是利用aop動態(tài)切換
配置文件
pom包就不貼了比較簡單該依賴的就依賴,主要是數(shù)據(jù)庫這邊的配置:
mybatis.config-locations=classpath:mybatis/mybatis-config.xml spring.datasource.test1.driverClassName = com.mysql.jdbc.Driver spring.datasource.test1.url = jdbc:mysql://localhost:3306/test1?useUnicode=true&characterEncoding=utf-8 spring.datasource.test1.username = root spring.datasource.test1.password = root spring.datasource.test2.driverClassName = com.mysql.jdbc.Driver spring.datasource.test2.url = jdbc:mysql://localhost:3306/test2?useUnicode=true&characterEncoding=utf-8 spring.datasource.test2.username = root spring.datasource.test2.password = root
新聞標(biāo)題:在springboot中使用mybatis如何實現(xiàn)多數(shù)據(jù)源-創(chuàng)新互聯(lián)
文章起源:http://chinadenli.net/article8/dcpdip.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供域名注冊、網(wǎng)站內(nèi)鏈、網(wǎng)站制作、App開發(fā)、網(wǎng)站導(dǎo)航、微信公眾號
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)
猜你還喜歡下面的內(nèi)容