Java Articles
Articles that explore Java language features and JDK specifications as they relate to understanding Spring Boot.
-
How to Export and Import CSV in Spring Boot - Handling Character Encoding, Large Datasets, and Validation with OpenCSV
A practical guide to implementing CSV download/upload with Spring Boot and OpenCSV. Covers Shift_JIS/UTF-8+BOM support to prevent garbled text in Excel, memory-efficient output of large datasets with StreamingResponseBody, mapping with @CsvBindByName, and row-level validation with error-row return on import, all explained with code.
-
How to Run Startup Logic with CommandLineRunner and ApplicationRunner in Spring Boot
A guide to using CommandLineRunner and ApplicationRunner to run logic exactly once right after a Spring Boot application finishes starting. Covers minimal implementations, execution order with @Order, receiving startup arguments via ApplicationArguments, behavior on exceptions, and how to choose between @PostConstruct and ApplicationReadyEvent, all with practical examples.
-
Implementing a Synchronous HTTP Client with RestClient in Spring Boot 3.2 - Migrating from RestTemplate/WebClient
A hands-on guide to implementing RestClient, added in Spring Boot 3.2. This article covers GET/POST/PUT/DELETE with the fluent API, error handling with onStatus, connect/read timeouts, testing with MockRestServiceServer, migration steps from RestTemplate, and how to choose between WebClient and @HttpExchange.
-
How to Export and Read Excel Files in Spring Boot - Implementing Reports and Data Import with Apache POI
An implementation guide for exporting and reading Excel (xlsx) files with Spring Boot and Apache POI. Covers the basics of Workbook/Sheet/Cell, downloading via REST API, memory optimization for large datasets with SXSSFWorkbook, and parsing uploaded xlsx files, all with code examples.
-
How to Dynamically Generate PDFs in Spring Boot - Report Output with OpenPDF and Thymeleaf
Implementation guide for dynamically generating PDFs in Spring Boot. Covers license comparison of OpenPDF/iText/Flying Saucer, conversion from Thymeleaf templates, Japanese font embedding, and download implementation with REST API.
-
How to Reduce Boilerplate Code with Lombok in Spring Boot
A practical explanation of the roles and proper usage of Lombok annotations frequently used in Spring Boot development (@Data, @Builder, @RequiredArgsConstructor, @Slf4j, etc.). Also covers pitfalls when used with JPA Entity and how to combine it with constructor injection.
-
Customizing JSON Serialization with Jackson Configuration in Spring Boot - Date, Null Exclusion, and snake_case Guide
Solve common Jackson issues in Spring Boot such as 'LocalDateTime returned as array' and 'frontend requires snake_case'. This REST API implementation guide explains date formatting, null exclusion, snake_case conversion, and @JsonView/Mixin/custom Serializer with code examples.
-
How to Implement API Rate Limiting in Spring Boot - Limiting Request Count with Bucket4j and Filter
Step-by-step guide to implementing rate limiting per IP and per API key from scratch by combining Bucket4j with Spring Boot's Servlet Filter. Covers how to return HTTP 429 on limit exceeded, and clarifies the differences in use cases compared to Resilience4j @RateLimiter.
-
How to Use GraphQL with Spring Boot - Spring for GraphQL Basics and When to Use It vs REST API
Using Spring for GraphQL in Spring Boot 3.x, this guide covers schema definition, Query and Mutation Resolver implementation, handling N+1 problems with DataLoader, and integration with Spring Security. Includes a comparison with REST API to clarify when to choose GraphQL.
-
How to Use MongoDB with Spring Boot - From Spring Data MongoDB Basics to Queries and Aggregation
A step-by-step guide to integrating MongoDB into a Spring Boot application. A practical guide covering entity definition with @Document, CRUD operations with MongoRepository, query methods, custom queries with MongoTemplate, and Aggregation Pipeline — all through implementation code.
-
How to Automate Entity-DTO Mapping with MapStruct in Spring Boot
An implementation guide for auto-generating toDto()/toEntity() methods with MapStruct instead of writing them by hand. Covers adding dependencies, basic @Mapper usage, nested objects, custom conversions, and unit testing.
-
How to Implement Real-Time Communication with WebSocket in Spring Boot - Basics of STOMP and SockJS
Learn how to quickly run a broadcast-style chat with Spring Boot + STOMP + SockJS, explained through a three-layer structure of configuration class, @MessageMapping, and SimpMessagingTemplate. Covers one-to-one messaging, retrieving authenticated users via Principal, and scaling with an external broker.
-
How to Automatically Record Created and Updated Timestamps with JPA Auditing in Spring Boot
A guide to automatically recording entity creation and update timestamps using JPA Auditing in Spring Boot. Covers practical code for configuring @CreatedDate, @LastModifiedDate, @EnableJpaAuditing, and AuditorAware, including integration with Spring Security.
-
How to Create Custom Validation Annotations in Spring Boot - @Constraint/ConstraintValidator Implementation Guide
A step-by-step guide to creating custom validations with @Constraint and ConstraintValidator, covering three patterns: phone number format, email duplication check (using DI), and password confirmation (cross-field). Encapsulate rules that @NotBlank / @Pattern cannot handle into reusable annotations and consolidate validation logic scattered across the Service layer.
-
How to Implement Google Login (OAuth2) with Spring Boot
A step-by-step guide to implementing Google social login from scratch using Spring Security OAuth2 Client. Covers everything from how the OAuth2 authorization code flow works to application.yml configuration and UserInfo retrieval, while building an app that runs in a local environment.
-
Spring Boot JWT Authentication with Spring Security (Tutorial)
Build JWT authentication for a Spring Boot REST API from scratch. Covers token generation, validation, JwtAuthenticationFilter, and SecurityFilterChain configuration with complete code examples.