Spring Boot project structure.
A Spring Boot project uses the Maven or Gradle source layout: Java under src/main/java, everything else under src/main/resources, and an application class at the top of the package tree. This page lays it out, then shows Spring PetClinic mapped by Nodeway.
The conventional layout
A project from Spring Initializr, with one feature filled in:
- pom.xmlThe Maven build, or build.gradle for Gradle.
- src/main/java/com/example/demo/The root package.
- DemoApplication.java@SpringBootApplication and the main method.
- owner/One package per feature.
- OwnerController.java@Controller or @RestController with @GetMapping and the rest.
- OwnerRepository.javaA Spring Data repository interface.
- Owner.javaA JPA @Entity: one table.
- src/main/resources/Everything that is not Java.
- application.propertiesSettings, or application.yml.
- templates/, static/Server-rendered views and static files.
- src/test/java/Tests, in the same packages as the code they test.
How a request moves through it
- A mapping annotation such as
@GetMapping("/owners/{id}")routes the request to a controller method. - The controller calls a service or, in small apps, a repository. Spring injects both through the constructor.
- The repository reads and writes
@Entityclasses, which JPA maps to tables.
A real example: Spring PetClinic
spring-projects/spring-petclinic is the Spring Boot sample application. Nodeway mapped it at commit 6b2ad3e, from 28 November 2026. Most of it is Java: 30 files of 32, followed by Shell (2).
It is organised by feature: owners and pets, vets, and a system package for shared configuration, all below one root package.
- Source files
- 32
- Functions and classes
- 118
- Confirmed calls
- 83
- Routes
- 17
- Tables
- 6
Its folders
- src/main/java/org/springframework/samples/petclinic/30 files17 routes · 6 tables
- owner/package12 files13 routes · 4 tables
- vet/package6 files2 routes · 2 tables
- system/package5 files2 routes
- model/package4 files
Routes
Nodeway found 17 routes and linked 17 to the function that handles them. They by HTTP method: GET 12, POST 5. All are under src/main (17).
Some of them
| Route | Method |
|---|---|
| /welcome · src/main/java/org/springframework/samples/petclinic/system/WelcomeController.java | GET |
| /oupstriggerException · src/main/java/org/springframework/samples/petclinic/system/CrashController.java | GET |
| /vetsshowResourcesVetList · src/main/java/org/springframework/samples/petclinic/vet/VetController.java | GET |
| /ownersprocessFindForm · src/main/java/org/springframework/samples/petclinic/owner/OwnerController.java | GET |
| /owners/{ownerId}/pets/newinitCreationForm · src/main/java/org/springframework/samples/petclinic/owner/PetController.java | GET |
| /owners/{ownerId}/pets/{petId}/visits/newinitNewVisitForm · src/main/java/org/springframework/samples/petclinic/owner/VisitController.java | GET |
| /vets.htmlshowVetList · src/main/java/org/springframework/samples/petclinic/vet/VetController.java | GET |
| /owners/newinitCreationForm · src/main/java/org/springframework/samples/petclinic/owner/OwnerController.java | GET |
Data model
Nodeway found 6 database tables, defined with JPA. Code in the repository reads or writes 2 of them. The most used:
| Table | Used by |
|---|---|
| owners4 columns · src/main/java/org/springframework/samples/petclinic/owner/Owner.java | 6 read5 write |
| typessrc/main/java/org/springframework/samples/petclinic/owner/PetType.java | 2 read0 write |
| pets3 columns · links to types · src/main/java/org/springframework/samples/petclinic/owner/Pet.java | 0 read0 write |
| visits2 columns · src/main/java/org/springframework/samples/petclinic/owner/Visit.java | 0 read0 write |
| vets1 column · src/main/java/org/springframework/samples/petclinic/vet/Vet.java | 0 read0 write |
| specialtiessrc/main/java/org/springframework/samples/petclinic/vet/Specialty.java | 0 read0 write |
The full map, with its entry points, a traced request and the most-called code, is on the Spring PetClinic architecture page.
See your own project's structure
Nodeway reads a Spring Boot project on your own computer and draws its folders, files, functions, routes and tables, with the imports and calls between them. Open a folder and the map is drawn locally; nothing is uploaded. The getting started guide covers installing it, and the repo maps show 31 open-source projects mapped the same way.
Questions
Where should the main class go in Spring Boot?
In the root package, above every other package. @SpringBootApplication scans its own package and everything below it for components, so classes outside it are not picked up without extra settings.
Package by feature or by layer in Spring Boot?
Both are common. By layer puts every controller in one package and every repository in another. By feature, as PetClinic does, keeps an owner's controller, repository and entity together, so most changes stay inside one package.
Where does application.properties go?
In src/main/resources. Spring Boot reads application.properties or application.yml from there, along with profile files such as application-dev.properties.