Swiftorial Logo
Home
Swift Lessons
Tutorials
Learn More
Career
Resources

Spring Boot FAQ: Top Questions

21. How does Spring Boot support H2 Database for development?

Spring Boot provides seamless integration with the H2 in-memory database, ideal for development and testing purposes.

πŸ—ΊοΈ Setup:

  1. Add the spring-boot-starter-data-jpa and com.h2database:h2 dependencies.
  2. Configure the H2 console and datasource settings in application.properties.

πŸ“₯ Example:

spring.datasource.url=jdbc:h2:mem:testdb
spring.datasource.driverClassName=org.h2.Driver
spring.h2.console.enabled=true

πŸ† Expected Output:

Launch H2 console at /h2-console and interact with in-memory database.

πŸ› οΈ Use Cases:

  • Lightweight testing without external DB setup.
  • Rapid prototyping and schema validation.