1. Java Basics 1.1 What are the data types in Java? Primitive types: byte (1), char (2), short (2), int (4), long (8), double (8), float (4), boolean (1) Reference types: classes, interfaces, enums, arrays 1.2 Differences between object-oriented and procedural programming? Both are development parad...
Inversion of Control (IoC) represents a fundamental design principle where the responsibility for creating and managing component instances is delegated to a central container. This approach decouples components by removing the need for objects to instantiate their dependencies directly. The contain...
What Is IOC IOC stands for Inversion of Control. It delegates object creasion responsibilities to the Spring framework, thereby reducing project complexity and system coupling between components. web.xml Configuration <?xml version="1.0" encoding="UTF-8"?> <web-app xmlns...
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...
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...
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...
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-...
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...
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...
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...