Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 2

// Use Setter Injection---

When u have Optional Dependicy

//Use Constructor Injection


When u have mandatory dependices

// Circular Dependency
not allowed in Const. dependency

Q.. What is dependency Injection ?


--The Dependency injection is also reffer as inversion of control(IOC) . both ar
same WHEN
We r having a dependent class and the dependent class is actually using a object of
some other class. So we have to provid ethe object of other class to the object of
dependent class. this is called dependency injection.

in normal core java that dependency injection has to performed by us.


but on the other hand Spring framekork has the main feature is called the depedency
injection means using the spring framework actually we can automate the process of
injectiong of dependencies means Spriong container automatically search and
implement . so here we ar not injectiong by ourself instead of that Spring
framework has to do
.This is called IOC.

Q.. What is the Application Context and bean factory??

Q.. Why Spring Container is light weight container??


---U need not to install any server.Its just a simple java class that can be
activated in any aplication. its just a interface and then implemention . create
simple object
that it will be activated.

Q...What do u mean by Spring bean??


----Java object(Any pojo class)which is registered with the Spring container.
job-- creating the object , resolving the dependencies , calling init method ,
calling destroy method.

But in Normal java class :-JVM manage entire life cycle ..

Q..Diff btw Constructor and init method??


--constructor will be called by the jvm and init method will be called by the
Spring container.
--dependency injected value is not available inside the constructor but it will be
available inside the init method.

Q...What is Spring Container/iOC container?


It will manage all the life cycle of spring beans. in addition of this Spring
container perform the dependency resolution as well .
Dependency resolution will be done based on configuration.

Q.. Diff. btw destroy method and fianlize mthod?


--jvm: called finalize metjod
--Sprint container: destroy metjod.

--finalize metnod is not gurantee (beacuse we need to initaite the GC explicity)


whereas destroy method is guranteed.

Servlet Container && Spring Container??


--No Similarity...
Spring Container Job is to INversion of Control and dependency injection..NO
concern with Web application , Desktop application. No HTML , CSS, All about
Depencdency
Managment..

Servlet Container-- responsible for dynamic webpages..


html code in java
Servlet--HTML in java
JSP -- java in html

Repository<T,ID> interface
| |
| |
| |
| |
| |
| |
| |
| |
| |
Crud Repository<T,ID> interface pagingAndSortingRepository<T,ID>
interface
| |
| |
ListCrudRepository ListPagingAndSortingRepository<T,ID>
interface
| |
jpa Repository___________________|

You might also like