Spring Project Layout
How a typical Spring Boot application is organized (the BookVault shape).
Package by feature
com.bookvault ├── BookVaultApplication.java ├── catalog/ (Book domain) ├── lending/ (Members & Loans) ├── security/ (auth & roles) ├── common/ (shared: error handling) └── config/ (OpenAPI, async, …)
group by domain area, not by layer
Inside a feature package
- Entity@Entity mapped to a table (Book.java)
- RepositorySpring Data interface (BookRepository)
- Servicebusiness logic, @Transactional (BookService)
- ControllerREST endpoints (BookController)
- dto/request/response records, kept off the entity
- *Exceptiondomain errors → ProblemDetail
Resources
src/main/resources/application.yml
externalized config…/application-<profile>.yml
per-environment overrides…/db/migration/V1__*.sql
Flyway schema migrationssrc/test/java/…
mirrors main; the test pyramid
Build & run
pom.xml / build.gradle
dependencies & plugins./mvnw spring-boot:run
run in dev./mvnw test
unit + slice + integration tests./mvnw package
build the executable jar