Code Monkey home page Code Monkey logo

spring-boot-multidatasource's Introduction

简介

在单数据源项目中,spring-boot提供属性文件配置的方式,配置我们的数据源,如下:

#数据源配置
spring.dataSource......

如果项目需要多个数据源的话,spring-boot就没有更好的方式了,只能通过自己构造DataSource的spring bean了。

多数据源配置

  1. 单数据源情况和spring boot提供的方式是一样的。无须额外的学习
  2. 多数据源和单数据源配置方式差不多,代码如下:
spring.dataSource.........
spring.dataSource1........
spring.dataSource2........
....
spring.dataSource6........

代码上可以看出,配置方式和单数据源方式几乎一样,需要特别主要的是:这种通过属性配置来定义多数据源的数据源的个数是有限制的,最多7个数据源。这对绝大多数应用场景是远远足够了的。万一不够,我们还可以spring原生的方式:构建自己的DataSource对象放入spring容器中,效果也是一样的。

spring-boot-multidatasource's People

Watchers

 avatar

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.