Fading Coder

One Final Commit for the Last Sprint

Configuring MyBatis with Multiple Data Sources in Spring Boot

Confgiuring multiple databases in a single Spring Boot application with MyBatis requires defining separate DataSource, SqlSessionFactory, and SqlSessionTemplate beans per database, and mapping each mapper package to the appropriate factory/template. Maven dependencies <dependencies> <depend...

Implementing TCP Servers with Spring Boot Using BIO, NIO, and Netty

BIO (Blocking I/O) Blocking I/O dedicates a thread to each connection. Accept, read, and write operations block the calling thread until data is available or an operation completes. Under high concurrency this approach consumes many threads and context switches. BIO echo server BioEchoServer.java pa...

Streaming Server‑Sent Events with Spring Boot WebFlux and a JavaScript EventSource Client

Streaming updates from a Spring Boot WebFlux backend too a browser can be implemented with Server‑Sent Events (SSE). SSE uses a long‑lived HTTP connection where the server pushes events to the client, while the client remains read‑only. Compared with WebSocket, SSE is one‑directional (server → clien...

Handling invalid request target characters in Tomcat 8.5+ under RFC 7230/3986

Symptom Upgrading to Tomcat 8.5+ (including the embedded Tomcat in Spring Boot) may reject requests whose path or query contains characters such as {, }, [, ], |, \ and others. A typical failure looks like: java.lang.IllegalArgumentException: Invalid character found in the request target. The valid...

Connecting Multiple RabbitMQ Brokers in Spring Boot

Spring Boot’s AMQP auto-configuration is great for a single RabbitMQ broker, but many systems need to talk to more than one. To support multiple brokers, define separate ConnectionFactory, RabbitTemplate, RabbitAdmin, and listener container factory beans for each broker and mark one as primary. Conf...

Spring Boot MyBatis with Two MySQL DataSources Using Druid

Required dependencies application.properties: define two data sources and poooling Java configuration for both data sources MyBatis mappers for each data source Controller endpoints to verify both connecsions Sample project layout and test URLs Dependencies <!-- MySQL JDBC driver --> <depe...

Spring Boot and RabbitMQ: JSON Serialization for Producers and Listeners

RabbitMQ transports raw bytes. Too exchange domain objects as JSON, you can serialize manually or configure Spring AMQP to handle JSON automatically for both producers and consumers. Manual JSON serialization with ObjectMapper You can convert a POJO to JSON yourself and publish the resulting bytes....

Fix LocalDateTime deserialization errors when converting JSON to objects in Spring Boot

Symptom When a request body contains date-time strings such as "2020-05-04 00:00" and the target fields are of type java.time.LocalDateTime, Spring Boot (via Jackson) fails to deserialize: org.springframework.http.converter.HttpMessageNotReadableException: JSON parse error: Cannot deserial...

Implementing Login Enforcement in Spring Boot 2.x with a Custom Annotation and HandlerInterceptor

Most endpoints in many applications require authentication. In Spring Boot 2.x, a common pattern is to decorate controllers or handler methods with a custom annotation and enforce that contract via a HandlerInterceptor. This guide shows how to: Declare a marker annotation to indicate that an endpoin...

Building Service Registration and Discovery with Spring Boot and Spring Cloud Eureka

Overview Eureka, created by Netflix, is a registry for service discovery in microservice architectures. Each provider registers itself with Eureka, while consumers query Eureka to locate instances. Although Netflix has ended active maintenance of Eureka 2.x, the Eureka 1.x implementation in Spring C...