Integrate H2 database in your Spring Boot Application – Lab 3

Hi Readers,

I am happy to post another blog post on how to integrate H2 database in your Spring Boot Application.

In this tutorial we will be using the H2 database in embedded mode.

You have created a  spring boot application and like to integrate with h2 database.

In pom.xml add the below dependency.

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

In applciation.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 spring boot app.

Open a browser and type

http://localhost:8080/h2  to get the below image.

h2databasejosepraveen

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

h2databasejosepraveen1

If you get stuck, kindly comment below.

Ask me your questions/ doubt in quora.

Thanks for reading this post. Subscribe my blog for  some awesome posts.

Advertisements

One thought on “Integrate H2 database in your Spring Boot Application – Lab 3

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s