Coding With Fun
Home Docker Django Node.js Articles Python pip guide FAQ Policy

How to integrate spring boot with spring data jpa?


Asked by Maison York on Dec 12, 2021 Spring



Here, the most important point is to define the dependencies for Spring Boot JPA related. Unlike the spring MVC with hibernate integration, we do not need to define separate dependencies for both spring boot and spring data jpa. A single spring-boot-starter-data-jpa brings all the dependencies for Spring boot and data jpa.
Keeping this in consideration,
Spring Boot’s starter for Spring Data JPA adds the most common dependencies and a reasonable default configuration to your application. The only thing you need to add is the connection information for your database. But that doesn’t mean that you have to use these defaults.
In addition, Spring Integration’s JPA (Java Persistence API) module provides components for performing various database operations using JPA. You need to include this dependency into your project: The JPA API must be included via some vendor-specific implementation, e.g. Hibernate ORM Framework.
Furthermore,
We only need h2 and spring-data-starter-data-jpa dependencies to use H2 database with Spring Data JPA. For a Gradle project, add the following dependencies to your build.gradle file:
Additionally,
Spring Boot provides starter dependency spring-boot-starter-data-jpa to connect Spring Boot application with relational database efficiently. The spring-boot-starter-data-jpa internally uses the spring-boot-jpa dependency. Let's create a Spring Boot application that uses JPA to connect to the database.