Code Explainers

Spring code explainers

java
@Configuration
@EnableWebSecurity
public class OAuth2SecurityConfig {
 

How OIDC login works in Spring Security

oauth2 openid-connect authorization
Intermediate 8 steps
java
@RestController
@RequestMapping("/api/reports")
public class OrderReportController {
 

Streaming a CSV export in Spring

streaming csv-export backpressure
Intermediate 9 steps
java
@Repository
public interface OrderRepository extends JpaRepository<Order, Long> {
 
    @Query("""

Keyset pagination with Spring Data JPA

pagination cursor jpa
Advanced 8 steps
java
@RestController
@RequestMapping("/api/quotes")
public class QuoteStreamController {
 

Streaming market quotes with Spring WebFlux

reactive-streams backpressure server-sent-events
Advanced 9 steps
java
@Controller
public class BookController {
 
    private final BookService bookService;

Solving GraphQL N+1 with batch mapping in Spring

graphql n+1-problem batching
Intermediate 8 steps
java
@Component
required to import
public class OutboxEventPublisher {
 

The transactional outbox pattern in Spring

transactional-outbox event-driven reliability
Advanced 7 steps
java
@RestController
@RequestMapping("/api/payments")
public class PaymentController {
 

Polymorphic payment requests in Spring

polymorphic deserialization sealed interfaces bean validation
Advanced 7 steps
java
package com.example.payments.config;
 
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;

Configuring a Stripe RestClient in Spring

dependency-injection http-client configuration
Intermediate 7 steps
java
@RestController
@RequestMapping("/api/notifications")
public class NotificationStreamController {
 

Server-Sent Events per user in Spring

server-sent-events concurrency event-driven
Advanced 8 steps
java
package com.example.orders.repository;
 
import com.example.orders.domain.Order;
import org.springframework.data.jpa.repository.JpaRepository;

Projection interfaces in Spring Data JPA

projections jpql aggregation
Intermediate 7 steps
java
@RefreshScope
@Component
public class FeatureSettings {
 

Refreshable feature settings in Spring

caching configuration dependency-injection
Intermediate 7 steps
java
@Entity
@Table(name = "invoices")
@FilterDef(name = "tenantFilter", parameters = @ParamDef(name = "tenantId", type = String.class))
@Filter(name = "tenantFilter", condition = "tenant_id = :tenantId")

Multi-tenant row filtering with Hibernate in Spring

multi-tenancy hibernate filters request interceptor
Advanced 7 steps
java
@Configuration
@EnableIntegration
public class OrderProcessingFlow {
 

Building an order pipeline with Spring Integration

messaging pipeline enterprise integration patterns
Intermediate 9 steps
java
package com.acme.billing.config;
 
import org.flywaydb.core.Flyway;
import org.flywaydb.core.api.MigrationVersion;

Customizing Flyway migrations in Spring

database-migrations flyway dependency-injection
Intermediate 6 steps
java
package com.example.web.convert;
 
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;

A custom ISO-week Converter in Spring

type conversion value object immutability
Intermediate 5 steps
java
@RestController
@RequestMapping("/api/documents")
@RequiredArgsConstructor
public class DocumentController {

Method-level authorization with @PreAuthorize in Spring

authorization spel rest-api
Intermediate 7 steps
java
@WebMvcTest(OrderController.class)
class OrderControllerTest {
 
    @Autowired

Slicing the web layer with @WebMvcTest in Spring

testing mocking web-layer
Intermediate 9 steps
java
@Repository
public interface OrderRepository extends JpaRepository<Order, Long> {
 
    @EntityGraph(attributePaths = {"customer", "lineItems", "lineItems.product"})

Killing N+1 queries with @EntityGraph in Spring

orm fetching n+1-problem
Intermediate 5 steps