在springboot中使用mybatis如何實(shí)現(xiàn)多數(shù)據(jù)源-創(chuàng)新互聯(lián)

這篇文章給大家介紹在springboot中使用mybatis如何實(shí)現(xiàn)多數(shù)據(jù)源,內(nèi)容非常詳細(xì),感興趣的小伙伴們可以參考借鑒,希望對大家能有所幫助。

成都創(chuàng)新互聯(lián)是一家集網(wǎng)站建設(shè),市南企業(yè)網(wǎng)站建設(shè),市南品牌網(wǎng)站建設(shè),網(wǎng)站定制,市南網(wǎng)站建設(shè)報(bào)價(jià),網(wǎng)絡(luò)營銷,網(wǎng)絡(luò)優(yōu)化,市南網(wǎng)站推廣為一體的創(chuàng)新建站企業(yè),幫助傳統(tǒng)企業(yè)提升企業(yè)形象加強(qiáng)企業(yè)競爭力??沙浞譂M足這一群體相比中小企業(yè)更為豐富、高端、多元的互聯(lián)網(wǎng)需求。同時(shí)我們時(shí)刻保持專業(yè)、時(shí)尚、前沿,時(shí)刻以成就客戶成長自我,堅(jiān)持不斷學(xué)習(xí)、思考、沉淀、凈化自己,讓我們?yōu)楦嗟钠髽I(yè)打造出實(shí)用型網(wǎng)站。

說起多數(shù)據(jù)源,一般都來解決那些問題呢,主從模式或者業(yè)務(wù)比較復(fù)雜需要連接不同的分庫來支持業(yè)務(wù)。我們項(xiàng)目是后者的模式,網(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如何實(shí)現(xiàn)多數(shù)據(jù)源-創(chuàng)新互聯(lián)
文章起源:http://muchs.cn/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)請盡快告知,我們將會在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)

h5響應(yīng)式網(wǎng)站建設(shè)