본문 바로가기

Programming!

Spring Boot2 ddl-auto 적용 안됨

다중 Datasource의 문제.

spring:
  jpa:
    hibernate:
      ddl-auto: update
    show-sql: true

 

해서 properties로 설정. 

spring:
  jpa:
    show-sql: true
    properties:
      hibernate.hbm2ddl.auto: update
...

 

문제는 해결됨.

 

 

코드상 별도의 datasource 설정을 하고 있을테니 main/sub db properties 를 별도로 빼서 따로 관리하는 것이 좋더라.

 

spring:
....
  commerce-writer-datasource:
    ddl-auto: update
    hikari:
      driver-class-name: org.postgresql.Driver
      jdbc-url: jdbc:postgresql://localhost:5432/myapp-commerce
      username: admin
      password: admin123!
      minimum-idle: 2
      register-mbeans: true
      pool-name: main-writer-datasource
  
  ....
  
  community-writer-datasource:
    ddl-auto: none
    hikari:
      driver-class-name: org.postgresql.Driver
      jdbc-url: jdbc:postgresql://localhost:5432/myapp-community
      username: admin
      password: admin123!
      minimum-idle: 2
      register-mbeans: true
      pool-name: sub-writer-datasource