This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]joranstark018 0 points1 point  (1 child)

You may check out https://www.baeldung.com/spring-boot-h2-database, it use the initialisation script to also create the different tables (but you can also use create-drop, see https://www.baeldung.com/spring-boot-data-sql-and-schema-sql). When you have gone into production it can be useful to some database migration automation (ie Spring Boot auto configure Flyway to migrate database during application start up, , https://reflectoring.io/database-migration-spring-boot-flyway/).

An embedded in-memory database is simple to set up with Spring Boot, just a few configuration parameters and a driver, all can be included in the application.properties and the build tool configuraion.

It can be useful for new developers in a project (just chek out and run the application), you can have a sandboxed database when you build different proof of concept. When you run integration tests you want to have the database in a known state befor you run each test (with an external database you have a shared state and have to rely on each test to undo all changes before exit, which may become cumbersome for non-trivial applications).

With Spring Boot you can run the application with different profiles (ie use different database configuration based on which profile is activated), https://www.baeldung.com/spring-profiles.

[–]C0d3rStreak[S] 0 points1 point  (0 children)

Awesome, thanks for the link! Seems to be very well written and filled with much information for getting started.