Bean Auto-Wiring in Spring
1. Example: One Person and Two Pets
1.1 Cat class
public class Cat {
public void Cry() {
System.out.println("Hiss");
}
}
1.2 Dog class
public class Dog {
public void Cry() {
System.out.println("Bark");
}
}
1.3 People class
public class People {
private String name;
private Cat cat ...
Posted on Tue, 12 May 2026 18:10:11 +0000 by frenchpl
Inter-Aspect Communication in Spring AOP: Passing Data Between Advice Methods
Problem Statement
In a flash sale system, I encountered a scenario where one aspect handles Redis-based distributed locking and rate limiting, while another aspect is responsible for publishing order messages to a message queue. The core challenge: how to transmit data computed in the first aspect to the second aspect for further processing.
So ...
Posted on Sun, 10 May 2026 23:46:02 +0000 by Qben
Understanding Interceptors in Java Spring Applications
Core Concepts of Interceptors
In Spring applications, interceptors serve as middleware components designed to execute custom logic before or after HTTP requests are processed. Unlike Aspect-Oriented Programming (AOP), which targets method-level cross-cutting concerns, interceptors specifically focus on the request processing pipeline.
Intercept ...
Posted on Sun, 10 May 2026 20:04:06 +0000 by garethj
Practical Spring AOP Implementation: A Clear Guide
AOP enables method enhancement without modifying the original source code (enhancement = proxy).
AOP Pointcut Expression Syntax:
execution([access modifier] [return type] [full class path] [method name] ([parameter list]))
Example:
@Before(value = "execution(* com.example.service.AccountService.deposit(..))")
Join Point Any method w ...
Posted on Sun, 10 May 2026 07:57:51 +0000 by aahh
Java-Based Configuration in Spring 3.x and Beyond
Prior to the introduction of Spring 3.x, configuration in Spring primarily relied on XML files. With the release of Spring 3.x, JavaConfig was introduced as a method of configuration based on Java code. This approach allows developers to define Spring container configurations and manage Spring beans through Java code, eliminating the need for e ...
Posted on Fri, 08 May 2026 19:54:55 +0000 by EdN
Building a Spring-Integrated Custom Annotation for Bean Validation
Defining the Custom Constraint Annotation
import javax.validation.Constraint;
import javax.validation.Payload;
import java.lang.annotation.*;
@Constraint(validatedBy = RecordIdValidator.class)
@Target({ElementType.FIELD})
@Retention(RetentionPolicy.RUNTIME)
@Documented
public @interface RecordExists {
String message() default "The pr ...
Posted on Fri, 08 May 2026 17:54:33 +0000 by cmanhatton
Mastering Spring IoC Container and Dependency Injection
IoC Container Basics
The Spring IoC (Inversion of Control) container manages application components and their lifecycle. Instead of creating objects manually, you define beans in configuration, and the container handles instantiation and wiring.
Defining Beans
A bean definition specifies how an object should be created and managed. In XML confi ...
Posted on Fri, 08 May 2026 14:14:11 +0000 by SBukoski
Understanding Spring Transaction Management Fundamentals
Overview
Spring provides comprehensive transaction management capabilities through its abstraction layer over various transaction APIs. This framework simplifies handling database transactions by offering both programmatic and declarative approaches.
Core Interfaces
PlatformTransactionManager
The PlatformTransactionManager interface serves as t ...
Posted on Fri, 08 May 2026 10:36:51 +0000 by PHPnewby!
Implementing Scheduled Tasks with Quartz in Spring
Quartz Overview
Quartz is an open-source project specializing in job scheduling. It can be used standalone or integrated with the Spring framework, with the latter being the preferred approach in production environments. Quartz enables development of single or multiple scheduled tasks, each with configurable execution patterns such as hourly ex ...
Posted on Fri, 08 May 2026 03:41:56 +0000 by KoshNaranek
Integrating MyBatis with Spring Framework
MyBatis-Spring Integration
Before diving into the integration, let's review the core MyBatis components.
Entity Class
package com.example.entity;
public class User {
private Integer id;
private String username;
private String password;
@Override
public String toString() {
return "User{" +
...
Posted on Thu, 07 May 2026 15:42:21 +0000 by binarymonkey