spring-boot

java
package com.example.reference;

import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.Id;
import jakarta.persistence.Table;

Seed Reference Data at Boot with a Spring Boot ApplicationRunner

spring-boot seeding reference-data
by codesnips 4 tabs
java
package com.example.demo.config;

import com.github.benmanes.caffeine.cache.Caffeine;
import org.springframework.cache.CacheManager;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.cache.caffeine.CaffeineCacheManager;

Caching strategies with Spring Cache

java spring-boot caching
by David Kumar 2 tabs
java
package com.example.catalog.web;

import com.example.catalog.domain.Product;
import java.math.BigDecimal;

public record ProductResponse(

Paginated Product Search Endpoint with Spring Data JPA Specifications

spring-boot spring-data-jpa pagination
by codesnips 4 tabs
java
@RestController
@RequestMapping("/api/exports")
public class ExportController {

    private final CsvStreamWriter csvStreamWriter;

Streaming a Large CSV Export in Spring Boot with StreamingResponseBody

spring-boot streaming csv
by codesnips 4 tabs
java
@Configuration
@EnableAsync
public class AsyncConfig {

    @Bean(name = "orderExecutor")
    public ThreadPoolTaskExecutor orderExecutor() {

Debouncing Order Recalculations with Spring @Async and a Configured ThreadPoolTaskExecutor

spring-boot async thread-pool
by codesnips 3 tabs
java
package com.example.observability;

public final class CorrelationIdConstants {

    public static final String HEADER_NAME = "X-Correlation-Id";
    public static final String MDC_KEY = "correlationId";

Propagate a Correlation ID Through Every Log Line with an MDC Servlet Filter in Spring Boot

spring-boot logging mdc
by codesnips 4 tabs
java
package com.shop.orders.events;

import java.math.BigDecimal;
import java.time.Instant;

public record OrderPlacedEvent(

Transactional Domain Events With Spring's ApplicationEventPublisher and @TransactionalEventListener

spring spring-boot domain-events
by codesnips 4 tabs
java
package com.example.demo.controller;

import com.example.demo.dto.UserDTO;
import com.example.demo.dto.v2.UserDTOV2;
import com.example.demo.service.UserService;
import org.springframework.web.bind.annotation.*;

API versioning strategies

java spring-boot api-versioning
by David Kumar 4 tabs