spring-boot-2/4-6-multi-spring-data-jpa #28
Replies: 1 comment 1 reply
-
这两个数据源连接的都是MySQL, spring.datasource.primary.jdbc-url=jdbc:mysql://localhost:3306/test1
spring.datasource.primary.username=root
spring.datasource.primary.password=123456
spring.datasource.primary.driver-class-name=com.mysql.cj.jdbc.Driver
spring.datasource.secondary.jdbc-url=jdbc:mysql://localhost:3306/test2
spring.datasource.secondary.username=root
spring.datasource.secondary.password=123456
spring.datasource.secondary.driver-class-name=com.mysql.cj.jdbc.Driver
还得配置数据库方言呢 |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
spring-boot-2/4-6-multi-spring-data-jpa
Spring Boot 2.x基础教程:Spring Data JPA的多数据源配置 上一篇我们介绍了在使用JdbcTemplate来做数据访问时候的多数据源配置实现。接下来我们继续学习如何在使用Spring Data JPA的时候,完成多数据源的配置和使用。 添加多数据源的配置 先在Spring Boot的配置文件application.properties中设置两个你要链接的数据库配置,比如这样:
https://www.didispace.com/spring-boot-2/4-6-multi-spring-data-jpa.html
Beta Was this translation helpful? Give feedback.
All reactions