Posts

Showing posts from March, 2022

Data Structure

Image
Data Structures: A data structure is a particular way of organizing data in a computer so that it can be used effectively. The idea is to reduce the space and time complexities of different tasks. Below is an overview of some popular linear data structures. 1. Array 2. Linked List 3. Stack 4. Queue Array   The array is a data structure used to store homogeneous elements at contiguous locations. The size of an array must be provided before storing data.  Example:  For example, let us say, we want to store marks of all students in a class, we can use an array to store them. This helps in reducing the use of a number of variables as we don’t need to create a separate variable for marks of every subject. All marks can be accessed by simply traversing the array.  Linked List   A linked list is a linear data structure (like arrays) where each element is a separate object. Each element (that is node) of a list is comprised of two items – the data and a reference to th...

Spring @Bean Example? What does the @Bean annotation do in Spring Framework?

  1. What is @Bean Annotation in Spring Framework? Definition of the  @Bean  varies from simple to complex to explain. The description given by the Spring Framework document is that Beans are the objects in Spring that constitute the backbone of your application and are maintained by the Spring IoC container.  A bean is an object that a Spring IoC container instantiates, assembles, and generally manages. 2. Spring IOC Container The process of inversion of control (IoC) is when an object declares its dependencies rather than creating them. The task of generating such dependencies is delegated to an IoC container via this object. 3. Traditional Approach In below, there is an explanation of the traditional approach to building the beans in Spring. Here we get the  Student  and  Grade  classes as an example.      public   class   Student   {             private  Grade grade;   ...

Spring Boot Annotations

Image
Basically, there are 6 types of annotation available in the whole spring framework. 1. Spring Core Annotations 2. Spring Web Annotations 3. Spring Boot Annotations 4. Spring Scheduling Annotations 5. Spring Data Annotations 6. Spring Bean Annotations  Type 1:  Spring Core Annotations  Spring annotations present in the  org.springframework.beans.factory.annotation  and  org.springframework.context.annotation  packages are commonly known as Spring Core annotations. We can divide them into two categories: DI-Related Annotations @Autowired @Qualifier @Primary @Bean @Lazy @Required @Value @Scope @Lookup, etc. Context Configuration Annotations @Profile @Import @ImportResource @PropertySource, etc. A  DI (Dependency Injection) Related Annotations 1.1:  @Autowired @Autowired annotation is applied to the fields, setter methods, and constructors. It injects object dependency implicitly. We use @Autowired to mark the dependency that will be injected by ...