Spring Boot Roadmap
56 sections • 1063 topics
- 1. Creating Project with Spring Initializr
- Example: Generate project via curl
- 2. Using Spring Boot CLI
- 3. Configuring Maven Dependencies
- Example: Minimal pom.xml
- 4. Configuring Gradle Dependencies
- Example: build.gradle.kts
- 5. Setting Up Project Structure
- Recommended Package Layout
- 6. Configuring Application Main Class (@SpringBootApplication)
- Example: Main class with SpringApplication
- 7. Understanding Auto-Configuration Mechanism
- 8. Customizing Application Banner
- 9. Using Spring Boot DevTools
- Example: DevTools Maven dependency
- 10. Configuring Multi-Module Projects
- 11. Using Parent POM Inheritance
- 12. Managing Dependency Versions
- 1. Using application.properties File
- 2. Using application.yml Format
- Example: Equivalent YAML configuration
- 3. Understanding Property Precedence and Override Order
- 4. Using Profile-Specific Properties
- 5. Binding Properties with @Value Annotation
- Example: Constructor injection with @Value
- 6. Creating Type-Safe Configuration (@ConfigurationProperties)
- Example: ConfigurationProperties as record
- 7. Using Environment Variables and System Properties
- 8. Validating Configuration Properties (@Validated)
- Example: Validated configuration properties
- 9. Using Relaxed Binding Rules
- 10. Encrypting Sensitive Properties
- 11. Loading External Configuration Files
- 12. Using Random Values
- 1. Creating Profile-Specific Configurations
- 2. Activating Profiles (spring.profiles.active)
- 3. Using Multiple Active Profiles
- Example: Activate multiple profiles
- 4. Setting Default Profile (spring.profiles.default)
- 5. Using @Profile Annotation on Beans
- Example: Profile-bound bean
- 6. Using Profile Groups (spring.profiles.group)
- Example: Profile groups for production and qa
- 7. Using Profile Expressions (!, &, |)
- 8. Loading Profile-Specific YAML Documents
- Example: Multi-document YAML per profile
- 9. Detecting Active Profiles Programmatically
- Example: Read active profiles from Environment
- 10. Testing with Specific Profiles (@ActiveProfiles)
- Example: Activate test profile
- 1. Understanding Spring Boot Startup Sequence
- Boot Startup Phases
- 2. Using ApplicationRunner and CommandLineRunner
- Example: Seed data on startup
- 3. Implementing ApplicationContextInitializer
- Example: Inject property source on context init
- 4. Using SmartLifecycle for Custom Lifecycle Management
- 5. Handling Application Ready Events (ApplicationReadyEvent)
- Example: Warm caches on ApplicationReadyEvent
- 6. Handling Application Started Events
- 7. Handling Context Refresh Events
- Example: Handle ContextRefreshedEvent
- 8. Implementing Graceful Shutdown
- Example: Graceful shutdown with timeout
- 9. Using Exit Codes (ExitCodeGenerator)
- Example: Custom exit code with ExitCodeGenerator
- 10. Configuring Startup Actuator Endpoint
- Example: Buffer startup steps for /actuator/startup
- 1. Understanding Inversion of Control (IoC Container)
- 2. Creating Beans with @Component Annotation
- 3. Creating Beans with @Service Annotation
- Example: Service bean with constructor injection
- 4. Creating Beans with @Repository Annotation
- 5. Creating Beans with @Controller and @RestController
- Example: @Controller returning a view
- Example: @RestController returning JSON
- 6. Injecting Dependencies with @Autowired
- 7. Using Constructor Injection
- Example: Multi-dependency constructor injection
- 8. Using Setter Injection
- Example: Optional setter injection
- 9. Using Field Injection
- 10. Resolving Multiple Beans (@Qualifier, @Primary)
- Example: Primary and qualifier for multiple caches
- 11. Understanding Bean Scopes
- 12. Using Lazy Initialization (@Lazy)
- 1. Creating Java Configuration Classes (@Configuration)
- 2. Defining Beans with @Bean Methods
- Example: @Bean with init and destroy lifecycle
- 3. Setting Bean Names and Aliases
- 4. Using @ComponentScan for Auto-Detection
- Example: Selective component scan with exclusion
- 5. Importing Configurations (@Import, @ImportResource)
- 6. Using Conditional Beans (@Conditional)
- Example: OS-conditional bean
- 7. Using @ConditionalOnProperty Annotation
- Example: Property-gated feature bean
- 8. Using @ConditionalOnClass and @ConditionalOnMissingClass
- 9. Using @ConditionalOnBean and @ConditionalOnMissingBean
- Example: Default bean when none present
- 10. Ordering Beans with @Order and @Priority
- 11. Customizing Bean Lifecycle (@PostConstruct, @PreDestroy)
- Example: Lifecycle hooks: warm up and flush
- 12. Using InitializingBean and DisposableBean Interfaces
- 1. Creating REST Controllers (@RestController)
- Example: CRUD REST controller
- 2. Mapping HTTP Requests (@RequestMapping)
- 3. Using Specific HTTP Methods
- 4. Handling Path Variables (@PathVariable)
- Example: Multiple path variables
- 5. Handling Query Parameters (@RequestParam)
- 6. Handling Request Body (@RequestBody)
- Example: Validated request body with Location header
- 7. Returning Response Entity (ResponseEntity<T>)
- 8. Setting Response Status (@ResponseStatus)
- Example: @ResponseStatus on method and exception
- 9. Handling HTTP Headers
- 10. Using Content Negotiation
- 11. Implementing HATEOAS Links
- Example: HATEOAS self and collection links
- 12. Versioning REST APIs
- 1. Using @RequestBody for JSON Deserialization
- 2. Using @ResponseBody for JSON Serialization
- Example: @ResponseBody on @Controller method
- 3. Customizing Jackson ObjectMapper Configuration
- Example: Configure ObjectMapper with JavaTimeModule
- 4. Handling Date and Time Formats (@JsonFormat)
- Example: Format date-time field as ISO string
- 5. Ignoring Null Fields (@JsonInclude)
- 6. Using Custom Serializers and Deserializers
- Example: Custom serializer for value type
- 7. Working with Multipart File Uploads (MultipartFile)
- Example: Multipart file upload with path traversal guard
- 8. Configuring Max File Size
- Example: Multipart upload size limits
- 9. Handling Form Data (@ModelAttribute)
- Example: Form binding with validation
- 10. Using HttpServletRequest and HttpServletResponse
- 11. Using HttpEntity for Request/Response Handling
- Example: Echo request body with custom header
- 1. Using Bean Validation API
- 2. Validating Request Body (@Valid, @Validated)
- Example: Validate request body
- 3. Using Standard Constraints
- 4. Using Numeric Constraints
- 5. Using Pattern Matching
- 6. Creating Custom Validators (ConstraintValidator)
- Example: Custom @ValidSku constraint annotation
- 7. Handling Validation Errors (BindingResult)
- Example: Return field validation errors as map
- 8. Customizing Validation Messages
- Example: Custom validation message bundle
- 9. Using Validation Groups
- Example: Validation groups for create vs update
- 10. Validating Nested Objects (@Valid on fields)
- Example: Nested object and list validation
- 11. Using @Validated for Method-Level Validation
- Example: Method-level validation on service
- 1. Creating Global Exception Handlers (@ControllerAdvice)
- Example: Global exception handler with ProblemDetail
- 2. Handling Specific Exceptions (@ExceptionHandler)
- 3. Returning Custom Error Responses
- Example: Custom error response record
- 4. Using ResponseEntityExceptionHandler Base Class
- 5. Handling Validation Exceptions
- Example: Map validation errors to field messages
- 6. Handling HTTP Status Exceptions
- 7. Customizing Error Attributes (ErrorAttributes bean)
- Example: Inject trace ID into error attributes
- 8. Configuring Error Pages (ErrorController)
- 9. Logging Exceptions with Context Information
- Example: Log unhandled exception with trace context
- 10. Using Problem Details (RFC 7807)
- Example: RFC 7807 ProblemDetail with type URI
- 11. Handling Asynchronous Exception Handling
- 1. Configuring Data Source Properties
- 2. Creating Entity Classes (@Entity, @Table)
- Example: JPA entity with index and audit timestamps
- 3. Defining Primary Keys
- 4. Mapping Columns (@Column annotations)
- 5. Defining Relationships
- 6. Creating Repository Interfaces
- Example: Repository with derived query methods
- 7. Using Derived Query Methods
- 8. Writing Custom JPQL Queries (@Query)
- Example: Custom JPQL select and update queries
- 9. Using Native SQL Queries
- Example: Native query with interface projection
- 10. Implementing Pagination (Pageable, Page<T>)
- Example: Paginate with sort
- 11. Implementing Sorting
- 12. Using Query by Example
- Example: Query by example with null ignore
- 13. Using Specifications for Dynamic Queries
- Example: Dynamic query with Specification
- 1. Implementing One-to-One Relationships
- Example: Bidirectional one-to-one mapping
- 2. Implementing One-to-Many Relationships
- 3. Implementing Many-to-One Relationships
- Example: Many-to-one with lazy loading
- 4. Implementing Many-to-Many Relationships
- Example: Many-to-many with join table
- 5. Using Bidirectional Relationships
- 6. Using Cascade Operations
- 7. Configuring Fetch Types (LAZY vs EAGER)
- 8. Using @JoinColumn for Foreign Keys
- Example: JoinColumn with named FK constraint
- 9. Using @JoinTable for Join Tables
- 10. Handling Orphan Removal
- Example: Cascade delete with orphan removal
- 11. Using @EntityGraph for Fetch Optimization
- Example: Entity graph to avoid N+1
- 1. Understanding Entity States
- Entity State Transitions
- 2. Using Lifecycle Callbacks (@PrePersist, @PostPersist)
- Example: Auto-set timestamp and UUID on pre-persist
- 3. Using @PreUpdate and @PostUpdate Callbacks
- 4. Using @PreRemove and @PostRemove Callbacks
- Example: Clean up file on entity removal
- 5. Using @PostLoad Callback
- 6. Creating Entity Listeners (@EntityListeners)
- Example: Entity listener for audit events
- 7. Using Auditing (@CreatedDate, @LastModifiedDate)
- Example: Audit base entity with Spring Data auditing
- 8. Enabling JPA Auditing (@EnableJpaAuditing)
- 9. Using @CreatedBy and @LastModifiedBy
- Example: Current user from SecurityContext for auditing
- 10. Implementing Custom Auditing Logic
- 1. Understanding Transaction Management (@Transactional)
- Example: Transactional money transfer
- 2. Configuring Transaction Propagation
- 3. Setting Transaction Isolation Levels
- 4. Configuring Transaction Timeout
- Example: Transaction with timeout
- 5. Handling Read-Only Transactions
- 6. Rolling Back Transactions
- Example: Rollback rules and programmatic rollback
- 7. Using Programmatic Transactions (TransactionTemplate)
- Example: Programmatic REQUIRES_NEW transaction
- 8. Understanding Transaction Boundaries
- 9. Handling Distributed Transactions (JTA)
- 10. Using @Lock for Pessimistic Locking
- Example: Pessimistic write lock query
- 11. Using @Version for Optimistic Locking
- Example: Optimistic lock with @Version
- 12. Optimizing Transaction Performance
- 1. Configuring Flyway Migration Tool
- 2. Creating Flyway Migration Scripts
- Example: Flyway migration: create users table
- 3. Using Flyway Callbacks and Placeholders
- Example: Flyway schema placeholder
- 4. Configuring Liquibase Migration Tool
- 5. Creating Liquibase Changesets
- Example: Liquibase changeset for users table
- 6. Using Liquibase Contexts and Labels
- 7. Rolling Back Migrations (Liquibase)
- 8. Validating Migration Scripts
- 9. Using Baseline on Existing Databases
- Example: Flyway baseline for existing schema
- 10. Generating DDL from JPA Entities
- 11. Using Flyway vs Liquibase Comparison
- Flyway
- Liquibase
- 1. Adding Spring Data REST Dependencies
- Example: Spring Data REST dependency
- 2. Exposing Repository REST Endpoints
- Example: Auto-exposed REST repository
- 3. Customizing Base Path
- Example: Configure Data REST base path
- 4. Customizing Resource Names (@RepositoryRestResource)
- Example: Custom path, rel, and hide endpoint
- 5. Handling Projections and Excerpts
- Example: Projection with computed SpEL field
- 6. Implementing Custom Handlers (@RepositoryEventHandler)
- Example: Auto-assign UUID before create
- 7. Securing REST Endpoints
- Example: Method-level security on repository
- 8. Configuring CORS for REST APIs
- 9. Customizing HAL Response Format
- 10. Using Search Resources
- Example: Expose search endpoint by last name
- 11. Pagination and Sorting in Data REST
- 1. Adding Spring Security Dependencies
- Example: Spring Security dependencies
- 2. Configuring Security Filter Chain
- Example: Stateless JWT security filter chain
- 3. Using In-Memory Authentication
- Example: In-memory users with encoded passwords
- 4. Using JDBC Authentication
- Example: JDBC-backed user details
- 5. Implementing UserDetailsService Interface
- Example: Load user from database
- 6. Configuring Password Encoders
- Example: Delegating password encoder
- 7. Securing Endpoints with HTTP Security
- 8. Using Method-Level Security
- Example: Method security: role and ownership check
- 9. Configuring CORS
- Example: CORS configuration source bean
- 10. Implementing CSRF Protection
- 11. Configuring Session Management
- 12. Using Security Context (SecurityContextHolder)
- Example: Read username and roles from context
- 1. Understanding JWT Structure
- JWT Anatomy
- 2. Creating JWT Tokens
- Example: Issue JWT with claims and expiry
- 3. Validating and Parsing JWT Tokens
- Example: JWT decoder with secret key
- 4. Implementing JWT Authentication Filter
- Example: Configure JWT resource server
- 5. Configuring Token Expiration and Refresh
- 6. Storing User Details in JWT Claims
- Example: Map roles claim to authorities
- 7. Handling Token-Based Authorization
- Example: Access JWT claims in controller
- 8. Implementing Refresh Token Mechanism
- Refresh Token Rotation
- 9. Securing JWT Secret Keys
- 10. Handling Token Revocation Strategies
- 11. Using RS256 vs HS256 Algorithms
- HS256 (HMAC-SHA256)
- RS256 (RSA-SHA256)
- 1. Understanding OAuth 2.0 Flow Types
- 2. Configuring OAuth 2.0 Client
- Example: OAuth2 client dependency
- 3. Registering OAuth 2.0 Providers
- Example: Register Google OAuth2 provider
- 4. Implementing Authorization Code Flow
- Authorization Code Flow
- 5. Using OAuth 2.0 Login (oauth2Login())
- Example: Enable OAuth2 login with redirect
- 6. Accessing Protected Resources
- Example: Access OAuth2 token and OIDC user info
- 7. Implementing Resource Server
- Example: Resource server with JWKS URI
- 8. Validating JWT Access Tokens
- 9. Configuring OIDC User Info Endpoint
- 10. Customizing OAuth 2.0 Success/Failure Handlers
- Example: Custom OAuth2 success and failure handlers
- 11. Implementing Social Login Integration
- 1. Enabling Caching Support (@EnableCaching)
- Example: Enable caching support
- 2. Using @Cacheable for Method Results
- Example: Cache method result with condition
- 3. Using @CachePut for Cache Updates
- 4. Using @CacheEvict for Cache Removal
- Example: Evict by key and clear all entries
- 5. Configuring Cache Names and Keys
- 6. Using SpEL in Cache Annotations
- 7. Configuring Simple Cache Provider
- Example: Simple in-memory cache configuration
- 8. Integrating Redis Cache
- Example: Redis cache with TTL and JSON serializer
- Example: Redis cache type and connection
- 9. Integrating Caffeine Cache
- Example: Caffeine cache with size and expiry spec
- 10. Configuring Cache Expiration and TTL
- 11. Using @Caching for Multiple Operations
- Example: Combined cache put and evict
- 12. Implementing Custom Cache Manager
- Example: Two-level Caffeine + Redis cache manager
- 1. Enabling Async Support (@EnableAsync)
- Example: Enable async execution
- 2. Creating Async Methods (@Async)
- Example: Async email with CompletableFuture
- 3. Returning Future and CompletableFuture
- 4. Configuring Thread Pool Executor (TaskExecutor)
- Example: Thread pool executor for email tasks
- Example: Async task pool configuration
- 5. Handling Async Exceptions
- Example: Handle uncaught async exceptions
- 6. Using @Async with Transactions
- 7. Implementing Async REST Endpoints
- Example: DeferredResult and Callable endpoint
- 8. Using WebAsyncTask for Timeouts
- Example: Async task with per-request timeout
- 9. Configuring Async Request Processing
- 10. Using ListenableFuture for Callbacks
- 11. Testing Async Methods
- Example: Test async method with Awaitility
- 1. Enabling Scheduling (@EnableScheduling)
- Example: Enable task scheduling
- 2. Creating Scheduled Methods (@Scheduled)
- 3. Using Fixed Rate Execution
- Example: Fixed-rate scheduled task
- 4. Using Fixed Delay Execution
- Example: Fixed-delay with initial delay
- 5. Using Cron Expressions
- Example: Cron expressions with timezone
- 6. Configuring Initial Delay
- 7. Using Dynamic Scheduling (SchedulingConfigurer)
- Example: Dynamic cron from configuration
- 8. Configuring Task Scheduler Pool Size
- Example: Scheduler pool size configuration
- 9. Handling Scheduled Task Exceptions
- Example: Safe scheduled task with error logging
- 10. Using Time Zones in Cron Expressions
- 11. Testing Scheduled Tasks
- 1. Creating Custom Application Events
- Example: POJO event and legacy ApplicationEvent
- 2. Publishing Events (ApplicationEventPublisher)
- Example: Publish domain event after save
- 3. Creating Event Listeners (@EventListener)
- Example: Listen for domain event
- 4. Using Conditional Event Listening
- Example: Conditional event listener with SpEL
- 5. Implementing Async Event Handling
- Example: Async event handler
- 6. Ordering Event Listeners (@Order)
- 7. Using Transaction-Bound Events (@TransactionalEventListener)
- Example: Post-commit transactional event listener
- 8. Listening to Built-in Spring Events
- 9. Creating Generic Events (ResolvableTypeProvider)
- Example: Generic typed event with ResolvableType
- 10. Testing Event Publishing and Handling
- Example: Assert published events in test
- 1. Adding RabbitMQ Dependencies
- Example: RabbitMQ AMQP dependency
- 2. Configuring RabbitMQ Connection Properties
- 3. Creating RabbitTemplate for Sending Messages
- Example: Publish message with RabbitTemplate
- 4. Defining Queues, Exchanges, and Bindings
- Example: Declare queue, exchange, and binding
- 5. Sending Messages to Queues (convertAndSend)
- Example: Send message with headers and TTL
- 6. Creating Message Listeners (@RabbitListener)
- Example: Consume messages with concurrency
- 7. Configuring Message Converters (Jackson2JsonMessageConverter)
- Example: Configure JSON message converter
- 8. Handling Message Acknowledgments
- Example: Manual acknowledgement mode
- 9. Implementing Dead Letter Queues
- Example: Dead letter queue configuration
- 10. Using Message Properties and Headers
- 11. Configuring Retry and Error Handling
- Example: Retry with exponential backoff
- 12. Using Publisher Confirms and Returns
- Example: Publisher confirm and return callbacks
- 1. Adding Kafka Dependencies
- Example: Kafka dependency
- 2. Configuring Kafka Producer Properties
- Example: Kafka producer with idempotence
- 3. Configuring Kafka Consumer Properties
- Example: Kafka consumer with manual commit
- 4. Creating KafkaTemplate for Sending Messages
- Example: Send Kafka message with result callback
- 5. Sending Messages to Topics
- 6. Creating Kafka Listeners (@KafkaListener)
- Example: Consume Kafka record with manual ack
- 7. Configuring Consumer Groups
- 8. Handling Message Serialization
- 9. Managing Offset Commits
- 10. Implementing Error Handlers and Retry
- Example: Kafka dead letter publisher on failure
- 11. Using Kafka Headers and Timestamps
- Example: Access Kafka headers in listener
- 12. Using Kafka Streams for Processing
- Example: Kafka Streams filter to high-value topic
- 1. Adding WebSocket Dependencies
- Example: WebSocket dependency
- 2. Configuring WebSocket Message Broker
- Example: Configure STOMP broker over SockJS
- 3. Registering STOMP Endpoints
- 4. Configuring Message Broker
- Example: External RabbitMQ STOMP relay
- 5. Creating Message Handlers (@MessageMapping)
- Example: Chat message handler with @MessageMapping
- 6. Sending Messages to Clients (@SendTo)
- 7. Using SimpMessagingTemplate for Broadcasting
- Example: Broadcast and user-specific messaging
- 8. Handling User-Specific Messages (@SendToUser)
- Example: Send reply to user private queue
- 9. Implementing WebSocket Interceptors
- Example: Authenticate STOMP CONNECT with token
- 10. Handling WebSocket Events
- 11. Securing WebSocket Endpoints
- Example: WebSocket authorization by destination
- 1. Adding Spring WebFlux Dependencies
- Example: WebFlux dependency
- 2. Understanding Reactive Streams
- 3. Using Mono for Single Values
- Example: Mono: map and default value
- 4. Using Flux for Multiple Values
- Example: Flux: filter and limit stream
- 5. Creating Reactive REST Controllers
- Example: Reactive CRUD controller
- 6. Implementing Reactive Repositories
- 7. Using Reactive Database Drivers (R2DBC)
- Example: R2DBC datasource configuration
- 8. Handling Backpressure Strategies
- 9. Implementing Server-Sent Events
- Example: Server-sent events stream with Flux
- 10. Testing Reactive Endpoints (WebTestClient)
- Example: Test reactive endpoint with WebTestClient
- 11. Using Reactive Operators
- 1. Configuring R2DBC Data Source
- 2. Creating Reactive Entities (@Table)
- Example: R2DBC entity as record
- 3. Using ReactiveCrudRepository Interface
- Example: Reactive repository with Mono and Flux
- 4. Writing Custom Reactive Queries (@Query)
- Example: Reactive custom JPQL select and update
- 5. Implementing Pagination (Pageable)
- Example: Reactive pagination
- 6. Using Database Client (DatabaseClient)
- Example: Raw SQL query with DatabaseClient
- 7. Handling Transactions (TransactionalOperator)
- Example: Reactive transactional operator
- 8. Implementing Reactive Specifications
- 9. Using Reactive Caching
- Example: Reactive Redis cache-aside pattern
- 10. Testing Reactive Repositories (StepVerifier)
- Example: Test reactive repo with StepVerifier
- 11. Using R2DBC vs JDBC Comparison
- JDBC + JPA
- R2DBC
- 1. Configuring File Upload Properties
- 2. Handling Multipart File Uploads
- Example: Reactive multipart file info
- 3. Saving Files to Local Filesystem
- Example: Save file with path traversal guard
- 4. Generating Unique Filenames (UUID)
- 5. Serving Static Files
- Example: Serve uploaded files as static resource
- 6. Implementing File Download Endpoints
- Example: File download with Content-Disposition header
- 7. Streaming Large Files
- Example: Stream large file to response
- 8. Integrating AWS S3 for Cloud Storage
- Example: Upload to S3 and generate presigned URL
- 9. Using Spring Content for File Management
- 10. Validating File Types and Sizes
- Example: Validate file type and size
- 11. Implementing File Compression
- Example: Stream files as ZIP archive
- 1. Configuring JavaMailSender Properties (SMTP)
- Example: SMTP mail server configuration
- 2. Sending Simple Text Emails
- Example: Send plain text email
- 3. Sending HTML Emails (MimeMessage)
- Example: Send HTML email with MimeMessage
- 4. Using Thymeleaf for Email Templates
- Example: Render Thymeleaf email template
- 5. Adding Email Attachments
- Example: Email attachment and inline image
- 6. Sending Emails Asynchronously (@Async)
- Example: Send email asynchronously
- 7. Configuring Email Authentication
- 8. Using Gmail SMTP Server
- 9. Handling Email Sending Exceptions
- Example: Handle mail send exceptions
- 10. Testing Email Functionality (GreenMail)
- Example: Test email sending with GreenMail
- 1. Configuring Thymeleaf Template Engine
- Example: Thymeleaf dependency
- 2. Creating Thymeleaf Templates
- Example: Basic Thymeleaf template
- 3. Using Thymeleaf Expressions
- 4. Iterating Collections (th:each)
- Example: Iterate list with row status
- 5. Conditional Rendering (th:if, th:unless)
- 6. Including Fragments (th:fragment, th:replace, th:insert)
- Example: Fragment include across templates
- 7. Handling Form Binding (th:object, th:field)
- Example: Form binding with th:object and th:field
- 8. Using FreeMarker as Alternative
- Example: FreeMarker template syntax
- 9. Using Mustache Templates
- 10. Customizing Template Resolver Configuration
- Example: Custom template resolver for email
- 1. Configuring Message Sources (MessageSource)
- Example: Configure reloadable message source
- 2. Creating Message Properties Files
- Example: Message bundle with plural form
- 3. Creating Locale-Specific Files
- 4. Resolving Locale (LocaleResolver)
- 5. Using Accept-Language Header
- Example: Locale from Accept-Language header
- 6. Using Session/Cookie Locale Resolver
- Example: Locale stored in cookie
- 7. Accessing Messages in Controllers
- Example: Resolve i18n message in controller
- 8. Using Message Keys in Templates
- Example: Use message key in Thymeleaf template
- 9. Implementing Locale Change Interceptor
- Example: Change locale via query parameter
- 10. Formatting Dates and Numbers by Locale
- 11. Implementing URL-Based Locale Resolution
- Example: Resolve locale from URL path segment
- 1. Understanding Spring Boot Logging Defaults (Logback)
- 2. Configuring Log Levels
- Example: Log level per package
- 3. Using SLF4J Logger Interface
- Example: SLF4J parameterised logging
- 4. Logging with Different Levels
- 5. Configuring Logback XML
- Example: Logback JSON encoder for production
- 6. Using Log4j2 as Alternative
- Example: Switch logging to Log4j2
- 7. Logging to Files
- Example: Log to file with rolling pattern
- 8. Configuring Log Rotation and Archiving
- 9. Using MDC for Contextual Logging
- Example: Propagate trace ID with MDC filter
- 10. Logging HTTP Requests and Responses
- 11. Integrating with ELK Stack
- ELK Pipeline
- 12. Using Structured Logging
- Example: Logstash encoder dependency
- Example: Structured key-value log entry
- 1. Adding Spring Boot Actuator Dependency
- Example: Actuator dependency
- 2. Exposing Actuator Endpoints
- Example: Expose and configure actuator endpoints
- 3. Using Health Endpoint (/actuator/health)
- 4. Using Info Endpoint (/actuator/info)
- Example: Info endpoint with git and build metadata
- 5. Using Metrics Endpoint (/actuator/metrics)
- 6. Using Env Endpoint (/actuator/env)
- 7. Using Loggers Endpoint (/actuator/loggers)
- Example: Change log level at runtime via actuator
- 8. Using Thread Dump Endpoint
- 9. Using Heap Dump Endpoint
- 10. Using Beans Endpoint
- 11. Creating Custom Health Indicators
- Example: Custom health indicator with latency detail
- 12. Creating Custom Metrics (MeterRegistry)
- Example: Custom counter and timer metrics
- 13. Securing Actuator Endpoints
- Example: Restrict actuator to ADMIN role
- 1. Integrating Micrometer for Metrics
- 2. Configuring Prometheus Endpoint
- Example: Prometheus registry dependency
- Example: Prometheus endpoint with application tags
- 3. Exporting Metrics to Grafana
- Metrics Pipeline
- 4. Using Spring Boot Admin for Monitoring
- 5. Implementing Distributed Tracing (Micrometer Tracing)
- Example: OpenTelemetry tracing dependencies
- Example: Configure trace sampling and OTLP collector
- 6. Integrating with Zipkin for Trace Visualization
- 7. Configuring APM Tools
- 8. Monitoring JVM Metrics
- 9. Creating Custom Actuator Endpoints
- Example: Custom actuator endpoint with read and write operations
- 10. Using Liveness and Readiness Probes
- Example: Enable liveness and readiness probes
- 11. Implementing Custom Metrics with Tags
- Example: Counter metric with endpoint and status tags
- 1. Adding Springdoc OpenAPI Dependencies
- Example: Springdoc OpenAPI / Swagger UI dependency
- 2. Accessing Swagger UI
- 3. Accessing OpenAPI JSON
- Example: Configure Swagger UI path and options
- 4. Customizing API Info (@OpenAPIDefinition)
- Example: API info with contact and server definition
- 5. Documenting Operations
- Example: Document operation with response codes
- 6. Documenting Parameters
- Example: Document path parameter
- 7. Documenting Request/Response Models
- Example: Document response model with @Schema
- 8. Grouping APIs with Tags
- Example: Tag controller and group API paths
- 9. Adding Security Schemes
- Example: Bearer JWT security scheme
- 10. Customizing Swagger UI Configuration
- 11. Excluding Endpoints from Documentation
- Example: Hide internal endpoints from Swagger
- 12. Using Springdoc vs Springfox Comparison
- Springdoc
- Springfox
- 1. Using @SpringBootTest for Integration Tests
- Example: Integration test with MockMvc
- 2. Using @WebMvcTest for Controller Tests
- Example: Slice test for controller layer
- 3. Using @DataJpaTest for Repository Tests
- Example: Repository test against real database
- 4. Using @MockBean for Mocking Dependencies
- 5. Using MockMvc for REST API Testing
- 6. Testing with TestRestTemplate
- Example: HTTP client integration test
- 7. Using @Sql for Test Data Setup
- Example: Load and clean SQL test data
- 8. Configuring Test Properties (@TestPropertySource)
- Example: Override properties in test
- 9. Using Test Slices
- 10. Testing Security with @WithMockUser
- Example: Security test with mock user and JWT
- 11. Writing Unit Tests with JUnit 5 and Mockito
- Example: Unit test with Mockito mocks
- 12. Using Testcontainers for Integration Tests
- Example: Testcontainers with dynamic properties
- 13. Testing Async Methods and Events
- 1. Creating Servlet Filters (Filter interface)
- Example: Request timing filter
- 2. Registering Filters with FilterRegistrationBean
- Example: Register filter for /api/* with order
- 3. Ordering Multiple Filters (@Order)
- 4. Creating HandlerInterceptors
- Example: Audit interceptor recording start time
- 5. Registering Interceptors
- Example: Register interceptor with path exclusion
- 6. Using preHandle, postHandle, afterCompletion
- 7. Implementing Request Logging Filter
- Example: Configure Commons request logging filter
- 8. Implementing CORS Filter
- Example: CORS filter bean
- 9. Implementing Rate Limiting Filter
- Example: Per-IP rate limit filter with Bucket4j
- 10. Handling Filter Exceptions
- 11. Using OncePerRequestFilter for Single Execution
- 1. Creating Custom Annotations (@interface)
- Example: Custom @Auditable meta-annotation
- 2. Using Meta-Annotations
- 3. Implementing Annotation Processors
- 4. Using AOP for Annotation Processing (@Aspect)
- Example: AOP audit advice with execution time
- 5. Creating Validation Annotations
- Example: @StrongPassword validation annotation
- 6. Creating Security Annotations
- Example: Composed @AdminOrOwner security annotation
- 7. Creating Logging Annotations
- Example: Log execution time with AOP aspect
- 8. Using SpEL in Custom Annotations
- Example: SpEL key evaluation in rate limit aspect
- 9. Combining Multiple Annotations (@AliasFor)
- Example: @AliasFor composed request mapping annotation
- 10. Testing Custom Annotations
- 1. Enabling AspectJ Support (@EnableAspectJAutoProxy)
- Example: Enable AspectJ auto-proxy
- 2. Creating Aspect Classes (@Aspect, @Component)
- Example: Aspect bean with ordering
- 3. Defining Pointcut Expressions (@Pointcut)
- Example: Service method pointcut expression
- 4. Implementing Before Advice (@Before)
- Example: Before advice: log method entry
- 5. Implementing After Advice
- Example: After-returning and after-throwing advice
- 6. Implementing Around Advice (@Around)
- Example: Around advice: measure execution time
- 7. Accessing Method Parameters (JoinPoint)
- 8. Ordering Multiple Aspects (@Order)
- 9. Implementing Cross-Cutting Concerns
- 10. Using AspectJ Weaving
- Spring AOP (Proxy)
- AspectJ (Weaving)
- 11. Using this() vs target() in Pointcuts
- 1. Adding Spring Batch Dependencies (spring-boot-starter-batch)
- Example: Spring Batch dependency
- 2. Enabling Batch Processing (@EnableBatchProcessing)
- Example: Batch application entry point
- 3. Creating Job Configuration (Job, Step)
- Example: Job and chunk-oriented step
- 4. Implementing ItemReader for Data Input
- 5. Implementing ItemProcessor for Data Transformation
- Example: Normalize and filter items in processor
- 6. Implementing ItemWriter for Data Output
- Example: Batch writer using JPA repository
- 7. Configuring Chunk-Oriented Processing
- 8. Using FlatFileItemReader for CSV/TXT
- Example: Read CSV with FlatFileItemReader
- 9. Using JdbcBatchItemWriter for Database
- Example: Batch JDBC writer with named parameters
- 10. Implementing Job Parameters (JobParameters)
- Example: Build and run job with parameters
- 11. Scheduling Batch Jobs (@Scheduled)
- Example: Schedule nightly batch job
- 12. Monitoring Batch Job Execution (JobRepository)
- 13. Implementing Skip and Retry Logic
- Example: Fault-tolerant step with skip and retry
- 1. Adding Spring GraphQL Dependencies (spring-boot-starter-graphql)
- Example: GraphQL starter dependencies
- 2. Defining GraphQL Schema (schema.graphqls)
- Example: GraphQL schema: types, queries, mutations
- 3. Creating Query Resolvers (@QueryMapping)
- Example: Query resolvers for book and books
- 4. Creating Mutation Resolvers (@MutationMapping)
- Example: Mutation resolver: add book
- 5. Implementing Data Fetchers (DataFetcher)
- Example: Field resolver for book author
- 6. Handling Arguments (@Argument)
- 7. Using GraphQL Context (GraphQLContext)
- Example: Inject user into GraphQL context
- 8. Implementing Pagination (Connection pattern)
- Example: Cursor-based pagination schema
- 9. Implementing Error Handling (GraphQLError)
- Example: GraphQL exception resolver
- 10. Testing GraphQL Endpoints (GraphQlTester)
- Example: Test GraphQL query with GraphQlTester
- 11. Integrating with GraphiQL UI
- Example: Enable GraphiQL browser UI
- 12. Implementing Subscriptions for Real-Time Updates
- Example: GraphQL subscription with Flux
- 1. Adding gRPC Dependencies (grpc-spring-boot-starter)
- Example: gRPC server dependency
- 2. Defining Protocol Buffers (.proto files)
- Example: Proto definition for GreeterService
- 3. Generating Java Classes from Proto Files
- Example: Protobuf Maven plugin
- 4. Creating gRPC Server Services (@GrpcService)
- Example: Unary gRPC service implementation
- 5. Implementing Unary RPC Methods
- 6. Implementing Server Streaming RPC
- Example: Server-streaming RPC
- 7. Implementing Client Streaming RPC
- Example: Client-streaming RPC
- 8. Implementing Bidirectional Streaming RPC
- Example: Bidirectional streaming RPC
- 9. Creating gRPC Clients (gRPC stubs)
- Example: gRPC client with blocking stub
- 10. Handling gRPC Exceptions and Status Codes
- Example: Return gRPC NOT_FOUND status
- 11. Implementing gRPC Interceptors
- Example: Global gRPC server interceptor
- 1. Configuring Primary Data Source
- Example: Primary and secondary datasource config
- 2. Configuring Secondary Data Source
- Example: Multiple DataSource beans
- 3. Creating Multiple EntityManagerFactory Beans
- Example: Multiple EntityManagerFactory beans
- 4. Creating Multiple TransactionManager Beans
- Example: Multiple transaction managers
- 5. Separating Entity Packages by Data Source
- 6. Using @Primary for Default Data Source
- 7. Configuring JPA Repositories for Each Data Source
- Example: Route repositories to separate data sources
- 8. Handling Transactions Across Data Sources
- 9. Using Routing Data Sources (AbstractRoutingDataSource)
- Example: Routing DataSource by ThreadLocal key
- 10. Testing Multiple Data Sources
- 1. Creating RestTemplate for HTTP Requests
- Example: RestTemplate with timeout and base URL
- 2. Using WebClient for Reactive HTTP Requests
- Example: WebClient for reactive HTTP calls
- 3. Using RestClient for Modern HTTP Requests
- Example: RestClient for synchronous HTTP calls
- 4. Configuring Connection Timeouts
- 5. Handling HTTP Response Codes
- Example: Handle 4xx and 5xx with custom exceptions
- 6. Using RestTemplate Interceptors
- Example: Add bearer auth header via interceptor
- 7. Implementing Retry Logic for Failed Requests
- Example: Retry with backoff and recover fallback
- 8. Using Circuit Breaker with External APIs
- Example: Circuit breaker with fallback method
- 9. Handling API Authentication
- 10. Parsing JSON Responses (Jackson)
- Example: Deserialize generic list response
- 11. Testing External API Integration (MockRestServiceServer)
- Example: Mock REST server in test
- 12. Using Feign Client for Declarative REST Clients
- Example: Feign declarative HTTP client
- 1. Understanding Spring Boot Starter Structure
- Two-Module Layout
- 2. Creating Starter Module (spring-boot-starter-*)
- 3. Creating Auto-Configuration Classes (@AutoConfiguration)
- Example: Auto-configuration class
- 4. Using @ConditionalOnClass for Auto-Configuration
- 5. Creating Configuration Properties (@ConfigurationProperties)
- Example: Configuration properties as record
- 6. Registering Auto-Configuration (spring.factories, AutoConfiguration.imports)
- Example: Register auto-configuration via imports file
- 7. Implementing Fail-Fast Configuration Validation
- Example: Validated configuration properties for starter
- 8. Creating Starter Documentation
- 9. Publishing Custom Starters
- 10. Testing Custom Starters
- Example: Test auto-configuration with context runner
- 1. Enabling HTTP/2 Support
- Example: Enable HTTP/2 with TLS
- 2. Configuring GZip Compression (server.compression)
- Example: Enable GZip compression
- 3. Using Connection Pooling
- 4. Optimizing JPA Queries (N+1 problem)
- Example: JOIN FETCH to avoid N+1
- 5. Using Lazy vs Eager Fetching Strategies
- 6. Implementing Database Indexing
- Example: Composite index on JPA entity
- 7. Using Query Result Caching
- Example: Cache service method with Spring Cache
- 8. Configuring JVM Memory Settings (-Xmx, -Xms)
- 9. Profiling Application Performance
- 10. Using @EntityGraph for Fetch Optimization
- Example: EntityGraph for eager fetch
- 11. Implementing API Response Pagination
- Example: Paginated API response
- 12. Using Async and Non-Blocking Operations
- 13. Optimizing Spring Boot Startup Time
- 1. Adding Resilience4j Dependencies
- Example: Resilience4j dependencies
- 2. Implementing Circuit Breaker (@CircuitBreaker)
- Example: Circuit breaker on external service call
- 3. Configuring Circuit Breaker States (open, closed, half-open)
- State Machine
- Example: Circuit breaker thresholds configuration
- 4. Implementing Retry Mechanism (@Retry)
- Example: Retry on external service call
- 5. Configuring Retry Attempts and Delays
- Example: Retry with exponential backoff configuration
- 6. Implementing Rate Limiter (@RateLimiter)
- Example: Rate limiter: 100 requests per second
- Example: Apply rate limiter annotation
- 7. Implementing Bulkhead Pattern (@Bulkhead)
- Example: Semaphore bulkhead
- 8. Implementing Time Limiter (@TimeLimiter)
- Example: Time-limit async call
- 9. Monitoring Resilience Metrics (Actuator)
- 10. Combining Multiple Resilience Patterns
- Example: Combine circuit breaker, retry, and bulkhead
- 11. Using Fallback Methods
- 1. Using Bucket4j for Rate Limiting
- Example: Bucket4j dependencies
- 2. Configuring Rate Limits
- Example: Token bucket with 100 req/min bandwidth
- 3. Implementing Filter-Based Rate Limiting
- Example: Per-IP rate limit filter
- 4. Using Redis for Distributed Rate Limiting
- Example: Distributed rate limit dependencies
- 5. Implementing User-Based Rate Limits
- Example: Rate limit key: authenticated user or IP
- 6. Implementing Endpoint-Specific Rate Limits
- Example: Per-endpoint bandwidth limits
- 7. Returning Rate Limit Headers (X-RateLimit-*)
- 8. Handling Rate Limit Exceeded (429 Too Many Requests)
- Example: Respond with 429 Too Many Requests
- 9. Implementing Sliding Window Algorithm
- 10. Testing Rate Limiting Logic
- Example: Test rate limit exceeded
- 1. Setting Up Spring Cloud Config Server
- Example: Config server dependency
- Example: Enable config server
- 2. Configuring Config Server with Git Backend
- Example: Configure Git-backed config server
- 3. Using Config Client in Applications
- Example: Config client with fail-fast and retry
- 4. Managing Environment-Specific Configurations
- 5. Refreshing Configuration (@RefreshScope)
- Example: Refresh-scoped bean on POST /actuator/refresh
- 6. Encrypting Properties in Config Server
- Example: Encrypt and store secrets with config server
- 7. Using Config Server with Vault Backend
- Example: Vault-backed config server
- 8. Implementing Config Server Security
- Example: Secure config server with basic auth
- 9. Using Bus Refresh for Dynamic Updates
- Example: Spring Cloud Bus AMQP dependency
- 10. Testing Configuration Management
- 1. Adding Eureka Server Dependencies
- Example: Eureka server dependency
- 2. Configuring Eureka Server (@EnableEurekaServer)
- Example: Enable Eureka server
- Example: Standalone Eureka server configuration
- 3. Registering Services with Eureka Client
- Example: Eureka client dependency
- Example: Register service with Eureka
- 4. Using Service Discovery for Load Balancing
- Example: Load-balanced REST client via discovery
- 5. Implementing Health Checks for Services
- Example: Eureka health check integration
- 6. Configuring Eureka Client Properties
- 7. Using Consul as Alternative Discovery Service
- Example: Consul service discovery dependency
- Example: Consul discovery configuration
- 8. Implementing Client-Side Load Balancing (Spring Cloud LoadBalancer)
- 9. Using Service Names for Inter-Service Communication
- Example: Feign client with service discovery
- 10. Testing Service Discovery Integration
- 1. Setting Up Spring Cloud Gateway
- Example: API Gateway dependency
- 2. Configuring Route Definitions
- Example: Configure gateway routes with predicates
- 3. Using Predicates for Route Matching
- 4. Implementing Route Filters
- Example: Define routes via Java DSL
- 5. Using Built-in Filters
- 6. Creating Custom Gateway Filters (GatewayFilter)
- Example: Inject correlation ID at gateway
- 7. Implementing Rate Limiting at Gateway
- Example: Gateway rate limiter with Redis key resolver
- Example: Rate limit key resolver by principal
- 8. Configuring CORS at Gateway Level
- Example: Global CORS at gateway level
- 9. Implementing Authentication at Gateway
- Example: Gateway JWT security filter chain
- 10. Testing Gateway Routes and Filters
- Example: Test gateway route and response headers
- 11. Using Gateway with Service Discovery
- Example: Auto-route via service discovery
- 1. Creating Dockerfile for Spring Boot
- Example: Minimal Dockerfile with JRE
- 2. Using Multi-Stage Builds
- Example: Multi-stage Maven build
- 3. Building Docker Images (docker build)
- Example: Build and tag Docker image
- 4. Running Containers (docker run)
- Example: Run container with environment variables
- 5. Using Docker Compose (docker-compose.yml)
- Example: Docker Compose with database health check
- 6. Configuring Environment Variables
- 7. Managing Container Volumes
- Example: Bind mount config and log volume
- 8. Using Layered JAR Structure (spring-boot-jarmode-layertools)
- Example: Layered JAR Dockerfile
- 9. Optimizing Image Size
- 10. Publishing Images to Registry
- Example: Push image to container registry
- 11. Implementing Health Checks in Dockerfile
- Example: Dockerfile health check for liveness probe
- 1. Deploying to AWS Elastic Beanstalk
- 2. Deploying to AWS ECS/Fargate
- Example: ECS Fargate task definition
- 3. Deploying to Heroku (Procfile)
- Example: Heroku Procfile
- 4. Deploying to Google Cloud Run
- Example: Deploy to Google Cloud Run
- 5. Deploying to Azure App Service
- Example: Deploy to Azure App Service
- 6. Deploying to Kubernetes (Deployment, Service)
- Example: Kubernetes Deployment manifest
- 7. Creating Kubernetes ConfigMaps and Secrets
- Example: Create ConfigMap and Secret
- 8. Implementing Health Checks for Cloud Platforms
- 9. Using Cloud-Native Buildpacks
- Example: Build OCI image with Buildpacks
- 10. Configuring Auto-Scaling Policies
- Example: Horizontal Pod Autoscaler
- 11. Using Spring Cloud Kubernetes
- Example: Spring Cloud Kubernetes dependencies
- 1. Understanding GraalVM Native Image
- 2. Adding Native Build Tools Plugin
- Example: Add native Maven plugin
- 3. Configuring Native Image Properties
- Example: Configure GraalVM native build arguments
- 4. Building Native Images (native-image)
- Example: Compile and run native image
- 5. Handling Reflection Configuration
- Example: Register reflection hints
- 6. Configuring Resource Bundles
- Example: Register resource and message bundle hints
- 7. Optimizing Native Image Startup Time
- 8. Using Native Image with Docker
- Example: Native image Dockerfile with distroless
- 9. Testing Native Images
- Example: Run tests in native image
- 10. Troubleshooting Native Image Build Issues
- 1. Resolving Bean Creation Exceptions
- 2. Fixing Circular Dependency Issues
- Example: Fix circular dependency with @Lazy
- 3. Debugging Auto-Configuration Problems
- 4. Resolving Port Already in Use (server.port)
- Example: Find port conflict and use random port
- 5. Fixing ClassNotFoundException and NoClassDefFoundError
- 6. Debugging Transaction Not Working Issues
- 7. Resolving Database Connection Pool Exhaustion
- 8. Fixing CORS Errors in Browser
- Example: Global CORS mapping via WebMvcConfigurer
- 9. Debugging 404 Not Found Errors
- 10. Resolving Memory Leaks and OutOfMemoryError
- Example: JVM flags for heap dump on OOM
- 11. Troubleshooting Slow Application Startup
- 12. Fixing LazyInitializationException