Bean Scopes

In Spring Framework, a bean scope defines the lifecycle and visibility of a bean in the Spring IoC container—basically how and when the bean is created and how many instances exist. Common Bean Scopes in Spring 1. Singleton (default) Only one instance of the bean is created per Spring IoC container. All requests for…

0 Comments

Spring Bean

In Spring Boot, a bean is simply an object managed by the Spring IoC (Inversion of Control) container. Beans are the backbone of any Spring-based application. Spring automatically creates, wires, and manages their lifecycle, so you don’t need to manually instantiate or manage dependencies. 🔑 Ways to Define Beans in Spring Boot 1. Using…

0 Comments

Beans Conditional Creation

These annotations allow beans to be created only if certain conditions are met. Here’s a breakdown with examples: 1. Using @Conditional You can define your own condition by implementing Condition. import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Conditional; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Condition; import org.springframework.context.annotation.ConditionContext; import org.springframework.core.type.AnnotatedTypeMetadata; class MyCondition implements Condition { @Override public boolean matches(ConditionContext context, AnnotatedTypeMetadata metadata)…

0 Comments

Spring Boot web annotations

Spring Boot web applications rely heavily on annotations to configure controllers, handle requests, and define responses.Here’s a breakdown of the most commonly used Spring Web annotations with simple examples: 1. @RestController Combines @Controller and @ResponseBody. Marks a class as a web controller that directly returns data (usually JSON). import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.GetMapping; @RestController public…

0 Comments

Dependency Injection Spring boot

🔹 What is Dependency Injection? Dependency Injection (DI) is a design pattern where the Spring framework manages the creation and injection of objects (dependencies) into a class instead of the class creating them itself.This helps achieve loose coupling and makes the code more maintainable and testable. In Spring Boot, DI can be achieved mainly…

0 Comments

Spring Boot Starter

1. What is a Spring Boot Starter? A Spring Boot Starter is a dependency that simplifies adding libraries and configurations to your Spring Boot project.Instead of manually adding multiple dependencies and configurations, you can include a starter, and it will pull all necessary dependencies for you. For example: spring-boot-starter-web → for building REST APIs…

0 Comments

BeanFactory and ApplicationContext

1. Difference Between BeanFactory and ApplicationContext The BeanFactory is the core interface of the Spring IOC (Inversion of Control) container. It is responsible for instantiating, configuring, and managing beans. ApplicationContext is a more advanced Spring IOC container. It builds on BeanFactory and provides additional features like event handling, AOP support, and internationalization. FeatureBeanFactoryApplicationContextLoadingLazy (beans…

0 Comments

Service Locator Pattern

The Service Locator Pattern is a design pattern used to provide dependencies (services) to a client without exposing the creation logic. Instead of the client directly instantiating or managing services, it queries a Service Locator, which manages the lifecycle and lookup of services. It is often used to decouple service consumers from concrete implementations.…

0 Comments

Multilayer architecture

A multilayer architecture (also called n-tier architecture) is a way to structure an application into separate layers, each with a specific responsibility. This improves maintainability, scalability, and separation of concerns. Common Layers in Multilayer Architecture: Presentation Layer (UI Layer) Handles user interaction (e.g., web pages, desktop GUI). Example: JSP, Servlets, JavaFX, Swing. Business Logic…

0 Comments

Monolithic vs Microservices

1. Monolithic Architecture Definition: A monolithic application is built as a single unified unit. All components (UI, business logic, database access) are tightly coupled and run as a single process. Characteristics: Single codebase. Tightly coupled components. Easy to develop initially. Harder to scale or update parts independently. Deployment is all-or-nothing. Example: Imagine an e-commerce…

0 Comments

End of content

No more pages to load