Package com.example.springrest


package com.example.springrest
Application root package for the Spring Boot backend.

This package hosts the @SpringBootApplication entry point and forms the component-scan root for the project. Keeping the main application class here ensures that Spring discovers beans in all subpackages automatically.

Package layout

  • models – JPA entities (domain/persistence layer).
  • dto – Request/response Data Transfer Objects.
  • mappers – MapStruct mappers (entity ↔ DTO).
  • repositories – Spring Data JPA repositories.
  • services – Application/business logic.
  • controllers – Web layer (REST endpoints).
  • exceptions – Custom exceptions & (optionally) handlers.
  • { config} – Application/Web configuration (e.g., CORS, OpenAPI).

Conventions

  • Component scanning: Place SpringRestApplication in this package so @ComponentScan (implied by @SpringBootApplication) picks up all subpackages.
  • Persistence: If entities or repositories are moved outside this base package, configure @EntityScan and @EnableJpaRepositories explicitly.
  • API surface: Expose DTOs from dto in controllers; keep entities internal.
  • Transactions: Apply @Transactional on service methods that write.

Typical entry point


 package com.example.springrest;

 import org.springframework.boot.SpringApplication;
 import org.springframework.boot.autoconfigure.SpringBootApplication;

 @SpringBootApplication
 public class SpringRestApplication {
     public static void main(String[] args) {
         SpringApplication.run(SpringRestApplication.class, args);
     }
 }
 

Notes

  • Profiles: Use application-<profile>.yaml for environment overrides.
  • Docs: Javadoc is published with the site; OpenAPI/REST Docs can be added later.