How To Generate A Schema Via schema-*.sql
In MySQL
Note: As a rule, in real applications avoid generating schema via hibernate.ddl-auto
. Use schema-*.sql
file or better Flyway
or Liquibase
migration tools.
Description: This application is an example of using schema-*.sql
to generate a schema(database) in MySQL.
Key points:
- in
application.properties
, set the JDBC URL (e.g.,spring.datasource.url=jdbc:mysql://localhost:3306/bookstoredb?createDatabaseIfNotExist=true
) - in
application.properties
, disable DDL auto (just don't add explicitly thehibernate.ddl-auto
setting) or set it tovalidate
- in
application.properties
, instruct Spring Boot to initialize the schema fromschema-mysql.sql
file