Spring Data JPA 다중 DataSource
application.properties 설정
spring.datasource.primary.jdbc-url=jdbc:mysql://localhost:3306/test1
spring.datasource.primary.username=root
spring.datasource.primary.password=root
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=root
spring.datasource.secondary.driver-class-name=com.mysql.cj.jdbc.Driver
# SQL Log 출력 여부
spring.jpa.show-sql=true
# Hibernate 의 DDL 수행 전략
spring.jpa.hibernate.ddl-auto=create-dropapplication.yml 설정
spring:
datasource:
primary:
driver-class-name: com.mysql.cj.jdbc.Driver
jdbc-url: jdbc:mysql://localhost:3306/test1
password: root
username: root
secondary:
driver-class-name: com.mysql.cj.jdbc.Driver
jdbc-url: jdbc:mysql://localhost:3306/test2
password: root
username: root
jpa:
hibernate:
ddl-auto: create-drop
show-sql: true
Primary 설정
Secondary 설정
Last updated