Spring Framework Tutorial: Learncodewith Durgesh
Spring Framework Tutorial: Learncodewith Durgesh
Tutorial
Learncodewith Durgesh
Content
Spring Data
Spring Core Spring WEB
Integration
Learncodewith Durgesh
Prerequisite of course
Servlet &
Core java JDBC
JSP
Learncodewith Durgesh
Why Learncodewith Durgesh
1. To the point content.
4. Industry approach
Learncodewith Durgesh
Support us
1. Subscribe to my channel(Learncodewith Durgesh)
2. Follow on Instagram(@Durgesh_k_t)
https://courses.onlyjavatech.com/about
Learncodewith Durgesh
What is Spring?
Learncodewith Durgesh
What is Spring?
Spring is a Dependency Injection framework to
make java application loosely coupled.
Learncodewith Durgesh
Dependency Injection
It is design pattern
}
Inversion Of Control (IOC) Learncodewith Durgesh
Spring and JEE
Strut / JSF
Security
Business/Services ProductService
Transaction Layer
Management
inject
Spring JDBC Data Access Layer ProductDao
Spring ORM
DB
Learncodewith Durgesh
Spring Modules
Learncodewith Durgesh
Spring Modules
Access/Integration
JDBC ORM Web Servlet
Data
Web
JMS OXM Portlet WebSocket
Spring Framework
Test
Learncodewith Durgesh
Spring IoC Container
Learncodewith Durgesh
Spring IoC Container
Beans
Application
Code
Config
Learncodewith Durgesh
ApplicationContext
ClasspathXMLApplicationContext
AnnotationConfigApplicationContext
FileSystemXMLApplicationContext
Learncodewith Durgesh
Dependency Injection
Learncodewith Durgesh
Dependency Injection
class Student
{ class Address
{
int id; String street;
String name; String city;
Address address; String state;
String country;
} }
Learncodewith Durgesh
Dependency Injection
Can be done in 2 ways
Learncodewith Durgesh
Setter Injection
class Student
{
id,name,address class Address
{
setId(id){ } street,city,state,country
setStreet(street)
setName(name){ } setCity(city)
setState(state)
setAddress(address){ }
setCountry(country)
} }
Learncodewith Durgesh
Constructor Injection
class Student
{ class Address
String id,name,address;
{
Student(id,name,address) String street,city,state,country;
{ Address(street,city,state,country)
{
} }
}
}
Learncodewith Durgesh
Configuration File
Learncodewith Durgesh
Data Types( Dependencies)
1)Primitive DataTypes
Byte , short , char , int , float , double , long , boolean
Learncodewith Durgesh
Data Types
2)Collection Type
Learncodewith Durgesh
Life Cycle Methods
Spring provide two important methods
Initialization to every bean
code
Loading
config,
Connecting db,
Webservice etc public void init()
We can change the
name of these
method
public void destroy() But signature must
be
Clean up code same
Learncodewith Durgesh
Life Cycle
Spring bean
25
init()
Configuration
Xml File Then we Read and use the bean
destroy()
Configure Technique
Xml
Spring Interface
Annotation
Using Interfaces
InitializingBean
DisposableBean
Using Annotations
@PostConstruct
@PreDestory
Autowiring in Spring
• Feature of spring Framework in which spring container inject the
dependencies automatically .
Manually Automatically
<ref bean=""/>
Autowiring Modes
@Autowired
no
byName
byType
constructor
Autowiring Disadvantages
• No control of programmer.
• It can't be used for primitive and string
values.
Stereotype Annotations
• XML <bean />
@Component
Class Student
{
prototype
request
session
globalsession
Configure bean scope
@Component
@Scope( “ ”)
Class Student
{
}
SpEL Spring Expression Language
Supports Parsing and executing expression with the
help of @Value annotations
Expression @Value
and symbols
T(class).method(param)
T(class).variable
How to create objects?
new Object(value)