Giter VIP home page Giter VIP logo

springboot-mybatis-multi-datasource's Introduction

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.