
Spring
My simple learning archive covering the Spring ecosystem and modern Java.
The Spring Ecosystem
The complete module topology powering enterprise Java applications from core IoC container to cloud gateway routing.
[ THE SPRING ECOSYSTEM ]├── Spring Boot .........──> Pre-configures and runs applications instantly│ ├── spring-boot ............... (Core lifecycle, runner setup, and banner logic)│ ├── spring-boot-autoconfigure . (The "magic" engine that auto-wires beans)│ ├── spring-boot-actuator ...... (Production-ready monitoring & health endpoints)│ └── spring-boot-starters ...... (Pre-packaged dependency bundles like starter-web)│├── Spring Data .........──> Simplifies SQL/NoSQL database interactions│ ├── spring-data-commons ....... (The core interfaces & repository abstractions)│ ├── spring-data-jpa ........... (Relational database management via Hibernate)│ ├── spring-data-mongodb ....... (NoSQL document storage support)│ └── spring-data-redis ......... (Key-value memory cache support)│├── Spring Security ....──> Handles authentication, authorization, and safety│ ├── spring-security-core ...... (Core authentication & access control logic)│ ├── spring-security-web ....... (HTTP security filters and URL blocking rules)│ ├── spring-security-config .... (The Java configuration fluent API engine)│ └── spring-security-crypto .... (Password hashing, salts, and encryption tools)│├── Spring Cloud .......──> Manages microservices and distributed systems│ ├── spring-cloud-config ....... (Centralized server for managing environment properties)│ ├── spring-cloud-gateway ...... (API routing, security, and traffic throttling)│ └── spring-cloud-stream ....... (Event-driven messaging abstracting Kafka/RabbitMQ)│├── Spring Batch .......──> Processes massive volumes of background data│ ├── spring-batch-infrastructure (Low-level readers, writers, and retry mechanisms)│ └── spring-batch-core ......... (Job execution lifecycle, steps, and restart logic)│├── Spring Integration .──> Connects distinct enterprise systems together│ ├── spring-integration-core ... (The messaging pipelines, gateways, and channels)│ └── spring-integration-file ... (Specific adapters to stream external files/data pools)│├── Spring Shell .......──> Builds terminal-based command-line tools│ ├── spring-shell-core ......... (The terminal parsing engine and command UI)│ └── spring-shell-standard ..... (Built-in CLI commands like help, clear, and exit)│└── Spring Framework ...──> The foundation engine managing the core mechanics ├── spring-aop ................ (Aspect-Oriented Programming for logging/transactions) ├── spring-web ................ (Web integration, REST clients, and HTTP filters) ├── spring-context ............ (The Application Context registry holding beans) └── spring-core ............... (The absolute bedrock IoC and DI container utils)
Folder Structure Blueprint
Standard production layout for Maven & Spring Boot applications isolating source packages, static assets, configs, and build targets.
[organizationProject]/# The root project folder[organizationProject]/↳# The root project folder├── .mvn/# Hidden folder storing Maven Wrapper configurations├── .mvn/↳# Hidden folder storing Maven Wrapper configurations│ └── wrapper/│ ├── maven-wrapper.jar# Tiny binary that downloads/boots the Maven version│ ├── maven-wrapper.jar↳# Tiny binary that downloads/boots the Maven version│ └── maven-wrapper.properties# Properties file configuring the exact target Maven version│ └── maven-wrapper.properties↳# Properties file configuring the exact target Maven version├── src/# Source code root├── src/↳# Source code root│ ├── main/# Production-ready code and assets│ ├── main/↳# Production-ready code and assets│ │ ├── java/# Root directory for all Java source code packages│ │ ├── java/↳# Root directory for all Java source code packages│ │ │ └── [topLevelDomain]/│ │ │ └── [organizationProject]/│ │ │ └── [moduleName]/# Main application package matching Group + Artifact│ │ │ └── [moduleName]/↳# Main application package matching Group + Artifact│ │ │ └── Application.java# Main entry point class with main method│ │ │ └── Application.java↳# Main entry point class with main method│ │ └── resources/# Non-code assets used by your application│ │ └── resources/↳# Non-code assets used by your application│ │ ├── application.properties# Main configuration file (ports, DB URLs, log levels)│ │ ├── application.properties↳# Main configuration file (ports, DB URLs, log levels)│ │ ├── static/# Folder for static web frontend assets (HTML, CSS, JS)│ │ ├── static/↳# Folder for static web frontend assets (HTML, CSS, JS)│ │ └── templates/# Folder for server-side UI engine templates (Thymeleaf)│ │ └── templates/↳# Folder for server-side UI engine templates (Thymeleaf)│ └── test/# Test code root (isolated from production build)│ └── test/↳# Test code root (isolated from production build)│ └── java/# Root directory for unit tests and integration tests│ └── java/↳# Root directory for unit tests and integration tests├── mvnw# Executable Linux/macOS shell script for Maven Wrapper├── mvnw↳# Executable Linux/macOS shell script for Maven Wrapper├── mvnw.cmd# Executable Windows batch script for Maven Wrapper├── mvnw.cmd↳# Executable Windows batch script for Maven Wrapper├── pom.xml# Core configuration file managing versions & dependencies├── pom.xml↳# Core configuration file managing versions & dependencies└── target/# Autogenerated build output containing compiled .class & JARs└── target/↳# Autogenerated build output containing compiled .class & JARsSpring Web MVC Mechanics
Internal request dispatching via DispatcherServlet, HandlerMapping, and Jackson HttpMessageConverters.
HTTP Request
Client sends HTTP request to the Spring Boot application server.
GET /api/v1/products/42DispatcherServlet
Central Front Controller servlet receives the raw HTTP request and initiates dispatching.
Central InterceptorHandlerMapping
Matches URL pattern & HTTP method against registered @RequestMapping handler methods.
Finds @RestControllerController Execution
Invokes controller method, validates request DTOs, and queries @Service / @Repository layers.
@GetMapping ExecutionHttpMessageConverter
Jackson converts returned ProductDTO domain model into raw JSON bytes.
Java Record -> JSONHTTP 200 Response
DispatcherServlet flushes response stream back to client with HTTP 200 OK headers.
application/jsonGET /api/v1/products/42 HTTP/1.1
Host: api.primavera.dev
Accept: application/jsonData & State Representation
Holds application state, database entities (@Entity), and immutable Data Transfer Objects (Java Records).
Long id, String name, BigDecimal price
)
Presentation Serialization
Renders Model for consumer. In REST APIs, Spring uses Jackson2HttpMessageConverter to convert objects to JSON.
"id": 42,
"name": "Spring Boot Guide"
}
Routing & Orchestration
Intercepts HTTP requests via @RestController, validates payloads with @Valid, & delegates to Service layer.
public ProductDTO getProduct(...)
Modern Java 21+ Platform
Virtual Threads (Project Loom)
High-throughput, lightweight threads managed by the JVM instead of OS threads. Million-thread concurrency with traditional synchronous thread-per-request code.
try (var executor = Executors.newVirtualThreadPerTaskExecutor()) {
IntStream.range(0, 10_000).forEach(i -> {
executor.submit(() -> {
Thread.sleep(Duration.ofSeconds(1));
return i;
});
});
}Generational ZGC (Low-Latency)
Scalable zero-pause garbage collector capable of handling terabyte heaps with sub-millisecond maximum pause times.
# Enable Generational ZGC in Java 21+
java -XX:+UseZGC -XX:+ZGenerational -jar primavera-app.jarPattern Matching & Record Patterns
Deconstruct records directly in switch expressions with guards, enabling safe functional programming and algebraic type handling.
static String formatValue(Object obj) {
return switch (obj) {
case Point(int x, int y) -> "Point at (%d, %d)".formatted(x, y);
case String s when s.length() > 5 -> "Long string: " + s;
case Integer i -> "Number: " + i;
default -> "Unknown";
};
}Sealed Classes & Exhaustive Switches
Restrict subclassing to known permits, guaranteeing compile-time safety and eliminating the need for fallback default cases in switch statements.
public sealed interface PaymentMethod permits CreditCard, Crypto, BankTransfer {}
public record CreditCard(String cardNumber) implements PaymentMethod {}
public record Crypto(String walletAddress) implements PaymentMethod {}
public record BankTransfer(String iban) implements PaymentMethod {}