Difference between spring-data-jpa and spring-boot-starter-data-jpa
Master System Design with Codemia
Enhance your system design skills with over 120 practice problems, detailed solutions, and hands-on exercises.
Introduction
spring-data-jpa and spring-boot-starter-data-jpa are closely related, but they solve different dependency-management problems. The first is the core library that gives you repository support on top of JPA. The second is a Spring Boot starter that pulls that library in together with the pieces a Boot application usually needs for persistence.
What spring-data-jpa Actually Is
spring-data-jpa is the focused Spring Data module. It adds higher-level repository abstractions on top of the JPA specification.
It provides features such as:
- '
JpaRepositoryand related repository interfaces' - derived query methods such as
findByEmail - '
@Querysupport for JPQL and native SQL' - paging and sorting support
Example dependency:
By itself, that dependency is not a complete persistence runtime. You still need a JPA provider, transaction setup, a datasource, and a JDBC driver.
What the Boot Starter Adds
spring-boot-starter-data-jpa is a convenience bundle for Spring Boot applications. It includes spring-data-jpa, but also pulls in the supporting infrastructure that Boot expects to auto-configure.
Typical starter usage:
The Boot starter is not a different ORM. It is a curated dependency set plus auto-configuration support.
Manual Setup Versus Auto-Configuration
The practical difference is who assembles the persistence stack.
With spring-data-jpa directly, you wire most pieces yourself:
- datasource
- entity manager factory
- transaction manager
- repository scanning
- JPA provider settings
With the Boot starter, Boot auto-configures much of that when it detects the right dependencies and properties.
That is why a Boot application often needs only a few properties:
Example Repository Code
The repository code itself looks the same because the repository API comes from Spring Data JPA, not from the starter.
What changes is how much wiring you do around that repository.
When to Use Each One
Use spring-boot-starter-data-jpa when:
- you are building a normal Spring Boot application
- you want convention-based setup
- you want Boot to assemble the common persistence stack
Use spring-data-jpa directly when:
- you are not using Spring Boot
- you need unusually tight dependency control
- you already have a custom infrastructure layer
For most Boot projects, using the starter is the simpler and more maintainable choice.
A Simple Mental Model
Think of it this way:
- '
spring-data-jpagives you repository functionality' - '
spring-boot-starter-data-jpagives you repository functionality plus a Boot-friendly way to run it'
That distinction keeps dependency decisions clear and avoids treating the starter like a competing technology.
Common Pitfalls
- Thinking the starter is a different persistence framework. Fix: remember that the starter includes
spring-data-jpa; it does not replace it. - Forgetting the database driver dependency. Fix: add the correct JDBC driver for PostgreSQL, MySQL, H2, or whichever database you use.
- Using
spring-data-jpadirectly in a Boot app without a reason. Fix: prefer the starter unless you have a concrete reason to assemble dependencies manually. - Expecting Boot-style auto-configuration in a non-Boot application. Fix: configure datasource, transactions, and JPA infrastructure explicitly when not using Boot.
- Blaming repository code for startup failures caused by datasource configuration. Fix: separate repository API concerns from runtime wiring concerns when debugging.
Summary
- '
spring-data-jpais the core library that provides repository support on top of JPA.' - '
spring-boot-starter-data-jpais a Boot starter that includes that library and common supporting dependencies.' - The repository API is the same either way; the setup experience is different.
- Boot applications usually should use the starter.
- Non-Boot or highly customized applications may prefer the library directly.

