目錄
1.項(xiàng)目路徑
2.pom.xml? 引入依賴(lài):
3.application.yml配置文件:
4.兩個(gè)entity類(lèi)
5.Conroller
6.兩個(gè)Service以及兩個(gè)ServiceImpl?
7.兩個(gè)Mapper及兩個(gè)Mapper.xml?
8.運(yùn)行Application? 然后在瀏覽器請(qǐng)求
9.查看兩個(gè)數(shù)據(jù)庫(kù)是否有新增數(shù)據(jù)
1.項(xiàng)目路徑
2.pom.xml? 引入依賴(lài):
<dependency> <groupId>com.baomidou</groupId> <artifactId>dynamic-datasource-spring-boot-starter</artifactId> <version>3.5.0</version> </dependency>
3.application.yml配置文件:
4.兩個(gè)entity類(lèi)
?
5.Conroller
6.兩個(gè)Service以及兩個(gè)ServiceImpl?
?
7.兩個(gè)Mapper及兩個(gè)Mapper.xml?
?
?
?
8.運(yùn)行Application? 然后在瀏覽器請(qǐng)求
9.查看兩個(gè)數(shù)據(jù)庫(kù)是否有新增數(shù)據(jù)
總結(jié):
1.pom.xml 引入依賴(lài):dynamic-datasource-spring-boot-starter
2.在application.yml 中配置多個(gè)數(shù)據(jù)源信息(url,username,password等)文章來(lái)源:http://www.zghlxwxcb.cn/news/detail-662010.html
3.在service實(shí)現(xiàn)類(lèi)中需要加入@DS注解文章來(lái)源地址http://www.zghlxwxcb.cn/news/detail-662010.html
到了這里,關(guān)于【精·超詳細(xì)】SpringBoot 配置多個(gè)數(shù)據(jù)源(連接多個(gè)數(shù)據(jù)庫(kù))的文章就介紹完了。如果您還想了解更多內(nèi)容,請(qǐng)?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!