spring boot 2.0 配置双数据源 MySQL 和 SqlServer

参考:https://www.cnblogs.com/xiaofengfeng/p/9552816.html

安装

org.mybatis.spring.boot:mybatis-spring-boot-starter
mysql:mysql-connector-java
com.microsoft.sqlserver:mssql-jdbc

配置application.yml

spring:
  datasource:
    mysql:
      driver-class-name: com.mysql.jdbc.Driver
      jdbc-url: jdbc:mysql://172.16.0.1:3306/testdb1
      username: root
      password: root
    sqlserver:
      driver-class-name: com.microsoft.sqlserver.jdbc.SQLServerDriver
      jdbc-url: jdbc:sqlserver://dev1.test.com;databaseName=testdb2
      username: admin
      password: admin
  main:
    allow-bean-definition-overriding: true

 

posted @ 2019-02-22 14:20  bookc  阅读(1036)  评论(0编辑  收藏  举报