其他分享
首页 > 其他分享> > SpringBoot多数据源

SpringBoot多数据源

作者:互联网

<dependency>
    <groupId>com.baomidou</groupId>
    <artifactId>mybatis-plus-boot-starter</artifactId>
    <version>3.0.6</version>
</dependency>
<dependency>
	<groupId>com.baomidou</groupId>
	<artifactId>dynamic-datasource-spring-boot-starter</artifactId>
	<version>3.0.0</version>
</dependency>



spring:
 datasource:
	dynamic:
	  # 设置默认数据源为db1
	  primary: db1
	  datasource:
		db1:
		  url: jdbc:sqlserver://127.0.0.1:3000;DatabaseName=db1
		  driver-class-name: com.microsoft.sqlserver.jdbc.SQLServerDriver
		  username: sa
		  password: 123456
		db2:
		  url: jdbc:mysql://127.0.0.1:3306/db2
		  driver-class-name: com.mysql.jdbc.Driver
		  username: sa
		  password: 123456


@DS("db2")
public interface TestMapper extends BaseMapper<>{
}

标签:jdbc,SpringBoot,数据源,datasource,db1,db2,com
来源: https://blog.csdn.net/qq_23292875/article/details/120206526