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...
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 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...
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...
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...
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...
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....
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...
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...
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...