英文:
How to get ddl auto generated script in Spring boot JPA/Hibernate?
问题
有没有一种方法可以通过ddl-auto属性快速获取由Hibernate生成的数据库的初始SQL脚本?
我想要为Flyway获取一个初始的SQL脚本作为快速入门。
英文:
Is there a way to quickly get initial SQL script for the database that is being generated by hibernating through ddl-auto property?
I would like to get an initial SQL script for the flyway as a quick start.
答案1
得分: 1
-
使用属性
spring.jpa.show-sql = true
,它会在控制台以格式打印所有脚本。 -
像你之前做的那样使用
ddl-auto
,并为你的相应数据库备份模式,并将其用作初始脚本。
英文:
- use property
spring.jpa.show-sql = true
and it will print all script on console in format.
- use
ddl-auto
as you did and take backup of schema for your respective DB and use that as initial script
答案2
得分: -1
你可以通过在项目的 application.properties 文件中将 Hibernate 的日志级别设置为调试模式,来查看在 Spring Boot 应用程序中由 Hibernate 生成的 DDL 脚本。
logging.level.org.hibernate.SQL=DEBUG
英文:
You can see the DDL script generated by Hibernate in a Spring boot application by setting the logging level of Hibernate to debug mode in the application.properties file of your project.
logging.level.org.hibernate.SQL=DEBUG
专注分享java语言的经验与见解,让所有开发者获益!
评论