How to generate a ddl creation script with a modern Spring Boot + Data JPA and Hibernate setup?

前端 未结 3 1919
清酒与你
清酒与你 2020-11-30 23:51

Currently, I\'m using the default @SpringBootApplication annotation with the following properties in application.properties:

spring         


        
3条回答
  •  感情败类
    2020-12-01 00:11

    Ah, right after I posted this question a section of the spring data docs caught my eye:

    73.5 Configure JPA properties In addition all properties in spring.jpa.properties.* are passed through as normal JPA properties (with the prefix stripped) when the local EntityManagerFactory is created.

    So, to answer my own question: prefix the javax.persistence properties with spring.jpa.properties:

    spring.jpa.properties.javax.persistence.schema-generation.create-source=metadata
    spring.jpa.properties.javax.persistence.schema-generation.scripts.action=create
    spring.jpa.properties.javax.persistence.schema-generation.scripts.create-target=create.sql
    

    After doing this, the schema file was generated automatically in the project root.

提交回复
热议问题