Spring Data JPA without Spring Boot
System Design practice on Codemia
Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.
Introduction
Spring Data JPA works perfectly well without Spring Boot, but you have to provide all of the wiring that Boot would normally auto-configure for you. That means creating the DataSource, the entity manager factory, the transaction manager, and repository scanning explicitly. The upside is more control over the stack, which is useful in legacy Spring applications and modular systems that do not use Boot.
What You Must Configure Yourself
A non-Boot Spring Data JPA setup usually needs these pieces:
- JDBC
DataSource - JPA vendor adapter, often Hibernate
- '
EntityManagerFactory' - '
PlatformTransactionManager' - repository scanning with
@EnableJpaRepositories
If any one of these is missing, the repositories may compile but fail at runtime.
Java Configuration Example
The core configuration can be expressed in a Java @Configuration class.
This is the setup Boot would usually infer automatically.
Entity and Repository Look Familiar
Once the infrastructure exists, the entity and repository code looks almost the same as a Boot application.
The repository implementation is still generated by Spring Data at runtime.
Transactions Still Belong in the Service Layer
Repositories are not a substitute for clear transaction boundaries.
This is where write operations should usually be wrapped, not scattered across controllers or utility classes.
Version Consistency Matters
A common non-Boot problem is mixing incompatible generations of Spring, Hibernate, and JPA imports. For example, projects that use jakarta.persistence APIs need a compatible Spring and Hibernate stack. Older projects may still use javax.persistence.
The key rule is consistency across the whole dependency set.
Common Pitfalls
- Forgetting
@EnableJpaRepositories, which prevents repository beans from being created. - Configuring the entity manager factory but forgetting transaction management.
- Mixing
javax.persistenceandjakarta.persistenceimports in an incompatible stack. - Assuming Boot-style defaults exist when every key persistence bean must be wired manually.
- Putting transactional logic in the wrong layer instead of defining clear service-level boundaries.
Summary
- Spring Data JPA does not require Spring Boot, but it does require explicit infrastructure wiring.
- The key pieces are the data source, entity manager factory, transaction manager, and repository scanning.
- Entities and repositories look almost the same once the infrastructure is in place.
- Service methods should still define transaction boundaries clearly.
- Most non-Boot failures come from incomplete configuration or inconsistent dependency versions.
Related reading
- Spring Data rollback transaction on retry
- Spring data with cassandra giving IllegalStateException
- Spring embeddeb db table already exists error
- Spring Hibernate Query Plan Cache Memory usage
- Spring Embedded Kafka + Mock Schema Registry State Store ChangeLog Schema not registered
- Spring Expression Language SpEL check empty string?
- Spring is losing connection to the DB and does not recover or reconnect
- Spring JPA selecting specific columns

System Design Fundamentals
Build a strong foundation in designing scalable, reliable distributed systems.
View the courseTrack what you have practised
A free account saves your progress, solutions and study plan across every problem on Codemia.
System Design practice on Codemia
Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.