Fading Coder

One Final Commit for the Last Sprint

Transaction Propagation Behaviors and Programmatic Transactions in Spring @Transactional

Tarnsaction Propagation Behaviors in @Transactional Propagation Behaviors @Transactional(propagation = Propagation.REQUIRED) // Join existing transaction or create new one (default) @Transactional(propagation = Propagation.NOT_SUPPORTED) // Execute without transaction @Transactional(propagation = Pr...

Spring Bean Lifecycle: Destruction

Bean Destruction Lifecycle When the Spring container shuts down, it invokes the lifecycle methods for Bean destruction, as shown in the diagram below. Case Study: Closing Database Connections on Bean Destruction Consider a scenario where a database connection pool is managed as a Bean. Using the @Pr...

Understanding Bean Scopes in the Spring Framework

Spring’s default bean scope is singleton, where a single instance is created per container and shared across all request. The framework supports several scopes to manage bean lifecycle and visibility. Singleton: The default scope; one instance per Spring IoC container. Prototype: A new insatnce is c...

SSM Framework Integration Without Errors

Creating a Maven Project Start by creating a standard Maven Java project. Update pom.xml with the following dependencies: <?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-...

Optimizing Spring Application Performance and Startup Efficiency

Performance Analysis Tools for Spring Applications Several diagnostic tools can help analyze and improve Spring application performance: Arthas: A Java diagnostic tool for reall-time monitoring and troubleshooting Async Profiler: Low-overhead sampling profiler for Java applications Spring Boot Start...

Why MyBatis Mapper Interfaces Can Be @Autowired Like Ordinary Beans?

Case 1: Using MyBatis Alone Create a new configuration file mybatis-solo.xml in the resources directory with the fololwing content: <?xml version="1.0" encoding="utf-8"?> <configuration> <settings> <setting name="logImpl" value="LOG4J2"/&g...

Understanding Spring @Component Scanning Through Three Practical Examples

Example 1: Basic Spring Application The following demonstrates a simple bean registration using @Component annotation: @Component public class ServiceInstance { private String identifier = "serviceInstance"; public String getIdentifier() { return identifier; } public void setIdentifier(Str...

Understanding Spring's Auto-Configuration Mechanism Through @Import Analysis

Use Case Demonstration Example 1: @EnableXXX Annotation Usage In a Spring MVC project, adding the @EnableWebMvc annotation to a configuration class triggers Spring to automatically register a series of Spring MVC components, including HandlerMapping, HandlerAdapter, ViewResolver, and more. Example 2...

Inversion of Control and XML Dependency Injection in Spring

Inversion of Control (IoC) shifts the responsibility of object creation and lifecycle management away from the objects themselves, delegating it to an external container. Dependency Injection (DI) serves as the primary mechanism to achieve this, where required components are supplied to an object ra...

Aspect-Oriented Programming in Spring: Core Concepts and Practical Implementation

Aspect-Oriented Programming (AOP) complements Object-Oriented Programming (OOP) by enabling modularization of cross-cutting concerns — behaviors that span multiple classes, such as logging, security, or transaction management. Unlike OOP, which structures code around objects and inheritance, AOP all...