Skip to content

BowenSun90/Springboot-mybatis-multi-datasource

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GitHub Release

Springboot-mybatis-multi-datasource

Demo for Springboot project include mybatis multi-datasource

Springboot 集成mybatis 多数据源多项目实现

demo-jdbc-common

配置多个DataSource和Mapper,不通DataSource的Mapper放在不同的目录下,通过下面方式指定mapper用那个DataSource

@MapperScan(basePackages = "com.example.mapper.lib", sqlSessionFactoryRef = "primarySqlSessionFactory")

DataSource信息在使用者(demo-web)的properties中配置

spring.datasource.primary.url=jdbc:mysql://127.0.0.1:3306/lib
spring.datasource.primary.username=root
spring.datasource.primary.password=root
spring.datasource.primary.driver-class-name=com.mysql.jdbc.Driver

spring.datasource.secondary.url=jdbc:mysql://127.0.0.1:3306/web
spring.datasource.secondary.username=root
spring.datasource.secondary.password=root
spring.datasource.secondary.driver-class-name=com.mysql.jdbc.Driver

demo-libs

提供Service服务,连接一个DataSource

demo-web

提供Web服务,使用demo-libs提供的Service和自己连接的DataSource

MyBatis Code generator

Generator Config

Version

release-1.0

支持Spring 1.5.x

release-2.0

支持Spring 2.0.x Druid

About

Demo for Springboot project include mybatis multi-datasource

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages