Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between spring-data-jpa and spring-boot-starter-data-jpa

This may not be the best question to ask, but I noticed there are 2 Spring JPA for Spring boot. How are they different? Currently, I am trying to set up a Spring Boot 1.5.3 project along with Hibernate. I remember I had set up Spring Boot with JPA earlier with spring-boot-starter-data-jpa.

Most of the online examples I have seen as well as starter.spring.io provide the below dependency for Spring JPA.

<dependency>     <groupId>org.springframework.boot</groupId>     <artifactId>spring-boot-starter-data-jpa</artifactId> </dependency> 

But in one of the existing projects I came across spring-data-jpa:

<dependency>     <groupId>org.springframework.data</groupId>     <artifactId>spring-data-jpa</artifactId>     <version>1.11.4.RELEASE</version> </dependency> 

Doing a bit of Google did not give me if they are different or not.

In all my previous projects where I added JPA was though JPA 2.1/Hibernate that is why I am a bit unsure which of the 2 to use in my new Spring Boot application.

like image 543
Acewin Avatar asked Jun 26 '17 20:06

Acewin


People also ask

What is the difference between spring JPA and Spring Data JPA?

Spring data jpa- it is same like jpa means we can describe in below way. Spring Data Jpa is jpa data abstraction access which means it likes a jpa but it add some extra functionality, Without jpa we can not implement the spring data jpa.

What is spring-boot-starter-data-JPA?

Spring Boot JPA is a Java specification for managing relational data in Java applications. It allows us to access and persist data between Java object/ class and relational database. JPA follows Object-Relation Mapping (ORM). It is a set of interfaces.

What is the difference between spring boot and spring data?

Spring Boot contains all of the functionality of the standard Spring framework while also making application development much easier. When compared to Spring, you can get an application up and running in considerably less time because all Spring Boot attributes are auto-configured. So the answer is Spring Boot.

What is the difference between spring boot starter and spring boot starter web?

Difference Between Spring Boot Starter Web and Spring Boot Starter Tomcat. Spring Boot Starter Web is used for building RESTful applications using Spring MVC. Spring Boot Starter Tomcat is the default embedded container for Spring Boot Starter Web. We cannot exclude it while using web services.


1 Answers

As stated in the docs, the starter one is a convenient inliner for all required dependencies for this particular library, i.e. includes other dependencies in itself, instead of you writing those manually.

Look into the spring-boot-starter-data-jpa pom.xml, you will see there it includes spring-data-jpa as a dependency among many others.

Spring Boot Starters are a set of convenient dependency descriptors that you can include in your application. You get a one-stop-shop for all the Spring and related technology that you need without having to hunt through sample code and copy paste loads of dependency descriptors. For example, if you want to get started using Spring and JPA for database access just include the spring-boot-starter-data-jpa dependency in your project, and you are good to go.

like image 60
Artem Novikov Avatar answered Oct 11 '22 19:10

Artem Novikov