VOOZH about

URL: https://dzone.com/articles/integrate-h2-database-in-your-spring-boot-applicat

โ‡ฑ Integrate an H2 Database in Your Spring Boot App


Related

  1. DZone
  2. Coding
  3. Frameworks
  4. Integrate an H2 Database in Your Spring Boot App

Integrate an H2 Database in Your Spring Boot App

You have created a Spring Boot application and would like to integrate with an H2 database. What do you do?

By Jan. 01, 17 ยท Tutorial
Likes
Comment
Save
280.6K Views

Join the DZone community and get the full member experience.

Join For Free

In this tutorial, we will be integrating the H2 database in your Spring Boot application. Note that the H2 database is in the embedded mode.

You have created a Spring Boot application and would like to integrate with an H2 database.

In pom.xml, add the below dependency:

 <!-- H2 Database -->
 <dependency>
 <groupId>com.h2database</groupId>
 <artifactId>h2</artifactId>
 </dependency>

In the application.properties file, add the below line to enable the H2 database:

# H2
spring.h2.console.enabled=true
spring.h2.console.path=/h2

# Datasource
spring.datasource.url=jdbc:h2:file:~/test
spring.datasource.username=sa
spring.datasource.password=
spring.datasource.driver-class-name=org.h2.Driver

Take a Maven build and run the application as a Spring Boot app.

Open a browser and type http://localhost:8080/h2 to get the below image.

๐Ÿ‘ h2databasejosepraveen

The yellow highlighted lines should match your application.properties file.

๐Ÿ‘ h2databasejosepraveen1

That's it! If you get stuck, kindly comment below.

Spring Framework Spring Boot Database app Integration

Published at DZone with permission of Jose Praveen. See the original article here.

Opinions expressed by DZone contributors are their own.

Related

  • Improving Backend Performance Part 1/3: Lazy Loading in Vaadin Apps
  • Spring Config Integration With a PCF Application: A Step-by-Step Guide
  • Integrate Spring With Open AI
  • Enterprise RIA With Spring 3, Flex 4 and GraniteDS

Partner Resources

ร—

Comments

The likes didn't load as expected. Please refresh the page and try again.

Let's be friends: