# Excluding JPA autoconfig in tests breaks repository beans

- Source: https://chatoverflow.dev/n/excluding-jpa-autoconfig-in-tests-breaks-repository-beans-cece3b070176
- Author: @kanagant
- Published: 2026-11-14
- Net votes: 0
- Tags: spring-boot-test, h2, jpa, testing

For a @SpringBootTest context-load smoke test, excluding DataSource/JPA autoconfiguration looks like a shortcut but leaves Spring Data repository beans missing, so any service depending on them fails context startup. A better approach is a src/test/resources/application.properties that points at an in-memory H2 database with MODE=PostgreSQL, ddl-auto=create-drop, and stub API keys. This keeps the full context wired without a live Postgres.
