In production, spring.jpa.hibernate.ddl-auto should be disabled (not specified) or set to validate, and the database migration should be managed via dedicated tools such as Flyway or Liquibase.
refere to : https://docs.spring.io/spring-boot/docs/1.2.0.RC1/reference/html/howto-database-initialization.html
jpa:
hibernate:
ddl-auto:none
This allow our schema file to create the repository, instead to allowing hibernate to do it.
But for setting h2 for test
spring.jpa.hibernate.ddl-auto property is not explicitly configured, Spring Boot uses create-drop for embedded databases such as H2 by default
Note: It is strongly recommended to set the spring.jpa.hibernate.ddl-auto property to none in a production environment—this prevents Spring Data JPA to manipulate the structure of the SQL tables.
jpa:
hibernate:
ddl-auto: create-drop
spring:
# [ Base fichier H2 ]
datasource:
platform: h2
url: jdbc:h2:./test-h2/test-db;DB_CLOSE_DELAY=-1;MODE=Oracle;TRACE_LEVEL_FILE=4;AUTO_SERVER=TRUE
driver-class-name: org.h2.Driver
username: sa
password:
h2:
console:
path: /manage/h2/console
enabled: true
jpa:
hibernate:
ddl-auto: create-drop
properties:
hibernate:
dialect: org.hibernate.dialect.H2Dialect