Project structure

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.

Free to start. macOS (Apple silicon and Intel), Windows and Linux.

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 @Entity classes, 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

RouteMethod
/welcome · src/main/java/org/springframework/samples/petclinic/system/WelcomeController.javaGET
/oupstriggerException · src/main/java/org/springframework/samples/petclinic/system/CrashController.javaGET
/vetsshowResourcesVetList · src/main/java/org/springframework/samples/petclinic/vet/VetController.javaGET
/ownersprocessFindForm · src/main/java/org/springframework/samples/petclinic/owner/OwnerController.javaGET
/owners/{ownerId}/pets/newinitCreationForm · src/main/java/org/springframework/samples/petclinic/owner/PetController.javaGET
/owners/{ownerId}/pets/{petId}/visits/newinitNewVisitForm · src/main/java/org/springframework/samples/petclinic/owner/VisitController.javaGET
/vets.htmlshowVetList · src/main/java/org/springframework/samples/petclinic/vet/VetController.javaGET
/owners/newinitCreationForm · src/main/java/org/springframework/samples/petclinic/owner/OwnerController.javaGET

Data model

Nodeway found 6 database tables, defined with JPA. Code in the repository reads or writes 2 of them. The most used:

TableUsed by
owners4 columns · src/main/java/org/springframework/samples/petclinic/owner/Owner.java6 read5 write
typessrc/main/java/org/springframework/samples/petclinic/owner/PetType.java2 read0 write
pets3 columns · links to types · src/main/java/org/springframework/samples/petclinic/owner/Pet.java0 read0 write
visits2 columns · src/main/java/org/springframework/samples/petclinic/owner/Visit.java0 read0 write
vets1 column · src/main/java/org/springframework/samples/petclinic/vet/Vet.java0 read0 write
specialtiessrc/main/java/org/springframework/samples/petclinic/vet/Specialty.java0 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.

See your whole codebase in minutes.

Open a folder and Nodeway maps it on your own computer. No account, and nothing is uploaded.

More guides