1 Unstar Star 0 Fork 2

GSAM / mybadis-starter

Create your Gitee Account
Explore and code with more than 5 million developers,Free private repositories !:)
Sign up
This repository doesn't specify license. Without author's permission, this code is only for learning and cannot be used for other purposes.
spring-boot-mybadis-starter,支持多个数据源,一行注解完成配置 spread retract

Clone or download
Cancel
Notice: Creating folder will generate an empty file .keep, because not support in Git
Loading...
README.md

只需要一行注解,就可以配置mybadis的多数据源

这是一个基于spring boot 的mybadis的starter

支持多个数据源

使用方法很简单,先定义一些配置文件,放到application.yml中

mysql:
  server:
    saas:
      url: "jdbc:mysql://localhost:3306/saas?useUnicode=true&characterEncoding=utf8"
      username: root
      password: 123
      driverClassName: com.mysql.jdbc.Driver
      initialSize: 1  #初始化大小
      minIdle: 1  #空闲连接池的大小
      maxActive: 50 #最大激活数量
    saas2:
      url: "jdbc:mysql://localhost:3306/saas2?useUnicode=true&characterEncoding=utf8"
      username: root
      password: 123
      driverClassName: com.mysql.jdbc.Driver
      initialSize: 1  #初始化大小
      minIdle: 1  #空闲连接池的大小
      maxActive: 50 #最大激活数量

使用方法如下

@MyBadisLoader({"saas = com.llc.admin.web.dao.saas = classpath:mapper/*xml" , 
                "saas2 = com.llc.admin.web.dao.saas2 = classpath:mapper/*.xml,classpath:mapper/user/*.xml"})
@SpringBootApplication
public class WebApplication {

    public static void main(String[] args) {
        SpringApplication.run(WebApplication.class,args);
    }
}

上面的注解中 saas是上方配置文件,数据源的名称,后面是扫描的接口包名,可以用逗号分隔传入多个,再后面是扫描xml的配置文件路径,也支持多个 注解中接收的是一个数组,所以支持多个数据源,除此不需要任何代码就可以使用

Comments ( 0 )

Sign in for post a comment

1
https://gitee.com/dushuren/mybadis-starter.git
git@gitee.com:dushuren/mybadis-starter.git
dushuren
mybadis-starter
mybadis-starter
master

Search

131423 f1aaba0b 1899542 094922 1c74bed3 1899542