==>>What are the advantages of spring framework
Predefined Templates
Loose Coupling
Easy to test
Lightweight
Fast Development
Powerful Abstraction
Declarative support
==>>What are the modules of spring framework?
Test
Spring Core Container
AOP, Aspects and Instrumentation
Data Access/Integration
Web
==>>What is IOC and DI?
Spring IoC (Inversion of Control) Container is the core of Spring Framework. It
creates the objects,
configures and assembles their dependencies, manages their entire life cycle. The
Container uses
Dependency Injection(DI) to manage the components that make up the application. It
gets the information
about the objects from a configuration file(XML) or Java Code or Java Annotations
and Java POJO class.
These objects are called Beans.
Dependency Injection is the main functionality provided by Spring IOC(Inversion of
Control).
The Spring-Core module is responsible for injecting dependencies through either
Constructor or Setter methods.
The design principle of Inversion of Control emphasizes keeping the Java classes
independent of each other and
the container frees them from object creation and maintenance.
==>>Setter Dependency Injection
In this, the Dependency Injection will be injected with the help of setter and/or
getter methods. Now to set the Dependency
Injection as Setter Injection in the bean, it is done through the bean-
configuration file For this, the property to be set
with the Setter Injection is declared under the <property> tag in the bean-config
file.
==>>Constructor Dependency Injection
In Constructor Injection, the Dependency Injection will be injected with the help
of constructors.
Now to set the Dependency Injection as Constructor Dependency Injection in bean,
it is done through the bean-configuration file.
For this, the property to be set with the CDI is declared under the <constructor-
arg> tag in the bean-config file.
==>>What are the types of IOC container in spring?
BeanFactory
ApplicationContext
==>>What is the difference between BeanFactory and ApplicationContext?
BeanFactory is the basic container whereas ApplicationContext is the advanced
container. ApplicationContext extends the BeanFactory interface.
ApplicationContext provides more facilities than BeanFactory such as integration
with spring AOP, message resource handling for i18n etc.
==>> What is the difference between constructor injection and setter injection?
Constructor Injection Setter Injection
1) No Partial Injection Partial Injection
2) Desn't override the setter property Overrides the
constructor property if both are defined.
3) Creates new instance if any modification occurs Doesn't create new
instance if you change the property value
4) Better for too many properties Better for
few properties.