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.billing.config;

import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Configuration;

@Configuration

Type-Safe Spring Boot Config with @ConfigurationProperties Records and Validation

spring-boot configuration validation
by codesnips 4 tabs
java
package com.example.orders.event;

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

public final class OrderPlacedEvent {

Publishing Domain Events After Commit with @TransactionalEventListener in Spring Boot

spring-boot spring-events transactions
by codesnips 4 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
sql
CREATE TABLE country (
    code       CHAR(2)      PRIMARY KEY,
    name       VARCHAR(128) NOT NULL,
    currency   CHAR(3)      NOT NULL,
    updated_at TIMESTAMPTZ  NOT NULL DEFAULT now()
);

Seeding Reference Data After a Flyway Migration with a Java Callback

flyway spring-boot migrations
by codesnips 3 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
@RestController
@RequestMapping("/api/orders")
public class OrderController {

    private final OrderService orderService;

Testing a Spring Boot Controller Slice with @WebMvcTest, MockMvc and a Mocked Service

spring-boot testing mockmvc
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.search;

import java.time.LocalDate;

@ValidDateRange
public class DateRangeSearch {

Bind and Validate a Date-Range Search with @ModelAttribute and a Custom PropertyEditor

spring-boot spring-mvc data-binding
by codesnips 4 tabs