SlideShare a Scribd company logo
By→ Anuj Kumar Singh
What is Spring ?
1. Spring Framework is a open source Java Platform that provides
comprehensive infrastructure support for developing robust Java
application very easily and rapidly.
2. Spring framework was developed by Rod Johnson and was first
released in 2003 in Spring Organization now Pivotal.
3. Earlier name of Spring Framework was Interface21 later changed to
Spring based on Spring season.
4. Spring Framework is replacement of EJB’s (Enterprise Java Beans)
because of heavy weight of EJB’s
Why Spring ?
1. Spring is the most popular application development framework for
enterprise Java. Millions of developers around the world use Spring
Framework to create high performing, easily testable, and reusable
code.
2. Spring is lightweight when it comes to size and transparency. The
basic version of Spring framework is around 2MB.
3. The core features of the Spring Framework can be used in
developing any Java application, but there are extensions for
building web applications on top of the Java EE platform.
4. Spring framework targets to make J2EE development easier to use
and promotes good programming practices by enabling a
POJO-based programming model.
Advantages of Spring
1. Lightweight - Spring framework is lightweight because of its POJO
implementation.The Spring framework doesn’t force any
programmer to inherit any class or implements any interface. That
is why it is said non-invasive, Enable you to write powerful, scalable
applications using POJO.
2. Easy to develop J2EE application - The Dependency Injection
feature of Spring Framework and it support to various frameworks
makes the easy development of JavaEE application.
3. Easy to test - The Dependency Injection makes easier to test the
application. The EJB or Struts application require server to run the
application but Spring framework doesn't require server.
1. Loose Coupling - The Spring applications are loosely coupled
because of dependency injection and handles injecting dependent
components without a component knowing where they came from
(IoC).
2. Powerful abstraction - It provides powerful abstraction to JavaEE
specifications such as JDBC.
3. Declarative support - It provides declarative support for caching,
validation, transactions and formatting.
4. Portable - can use server - side in web/ejb app, client-side in swing
app, business logic is completely portable.
5. Lifecycle - Responsible for managing all your application
components, particularly those in the middle tier container sees
components through well-defined lifecycle: init(), destroy()
Modules of the Spring Framework
1. Core - Inversion of Control (IoC) and Dependency Injection.
2. AOP - These modules support aspect oriented programming
implementation where you can use Advices, Pointcuts etc. to
decouple the code.
3. DAO - Data Access Object support, transaction management,
JDBC-abstraction
4. ORM - Object Relational Mapping data access, integration layers
for Hibernate
5. MVC - Model-View-Controller implementation for web applications
6. Expression Language - It is an extension to the EL defined in JSP. It
provides support to setting and getting property values, method
invocation, accessing collections and indexers, named variables.
IOC and Dependency Injection
1. Dependency Injection is the main functionality provided by Spring
IOC (Inversion of Control).
2. The Spring-Core module is responsible for injecting dependencies
through either Constructor or Setter methods in POJO class.
3. Dependency Injection in Spring also ensures loose-coupling
between the classes.
Need for Dependency Injection:
1. Spring IOC resolves dependencies with Dependency Injection,
which makes the code easier to test and reuse.
2. Loose coupling between classes can be possible by defining
interfaces for common functionality and the injector will instantiate
the objects of required implementation.
Example
Tightly Coupling - (without IOC)
class Employee{
Address address;
Employee()
{address=new Address(“xyz street”, ”Lucknow”, ”UP”);
}}
One class object is created in another class in tight coupling.Leads to
a.Stop server
b.Recomplie
c.Create jar and war file
d.Redeploy
e.Restart the server.
Loose Coupling
1. with IOC (Constructor Injection)
class Employee{
Address address;
Employee(Address address)
{this.address=address;} }
2. with IOC (Setter Injection)
class Employee{
Address address;
public void setAddress(Address address)
{this.address=address;} }
No need to stop the existing component, in real time it is better.
Spring Architecture (Very loosely coupled, components widely reusable)
and separately packaged.
1. Spring allows to decouple software layers by injecting a
component’s dependencies at runtime rather than having them
declared at compile time via importing and instantiating classes.
2. Spring provides integration for J2EE services such as EJB, JDBC,
JNDI, JMS, JTA. It also integrates several popular ORM toolkits
such as Hibernate and JDO and assorted other services as well.
3. One of the highly touted
4. Spring is built on the principle of unchecked exception handling.
This also reduces code dependencies between layers. Spring
provides a granular exception hierarchy for data access operations
and maps JDBC, EJB, and ORM exceptions to Spring exceptions
so that applications can get better information about the error
condition.
Flow Control in Spring
How to Start Using Spring
1. create the class
2. create the xml file to provide the values
3. create the test class
4. Load the spring jar files
5. Run the test class
1. CLASS FILE - POJO (PLAIN OLD JAVA OBJECT)
2. TEST FILE - DAO (DATA ACCESS OBJECT)
3. BEAN FILE - XML
4. Load the jar files required for spring framework
There are mainly three jar files required to run this application.
1. org.springframework.core-3.0.1.RELEASE-A
2. com.springsource.org.apache.commons.logging-1.1.1
3. org.springframework.beans-3.0.1.RELEASE-A
5. Run the TEST FILE
Containers in Spring
1. Core Container (slower)
a. It is called Lazy Container.
b. It create object on demand one by one.
c. It will create the object when the bean file is loaded.
ClassPathResource res=new ClassPathResource(“Spring.xml”);
XmlBeanFactory fact=new XmlBeanFactory(res);
fact.getBean(“abc”);
2. J2EE Container (faster)
a. It is called Eager Container.
b. It create all object at once.
c. It cerate the object as soon as object of ApplicationContext is made.
ApplicationContext con=new
ClassPathXmlApplicationContext(“Spring.xml”);
Bean File
• Typical java bean with a unique id
• In spring there are basically two types
1. Singleton
One instance of the bean created and referenced each time it
is requested
<bean class=“bean.Test” id=“t” scope=“singleton”>
One object for all caller.
2. Prototype (non-singleton)
<bean class=“bean.Test” id=“t” scope=“prototype”>
multiple object i.e. one one object for each caller.
Spring framework Introduction

More Related Content

What's hot (20)

PPTX
Spring boot
Gyanendra Yadav
 
PDF
Introduction to Spring Framework
Hùng Nguyễn Huy
 
PPTX
Spring mvc
Pravin Pundge
 
PPTX
Introduction to Spring Framework
Serhat Can
 
PPTX
Introduction to Spring Boot
Purbarun Chakrabarti
 
PDF
Spring core module
Raj Tomar
 
PPTX
Spring boot Introduction
Jeevesh Pandey
 
PDF
JPA and Hibernate
elliando dias
 
PPT
Spring Core
Pushan Bhattacharya
 
PPS
Java Hibernate Programming with Architecture Diagram and Example
kamal kotecha
 
PPTX
Spring boot
Pradeep Shanmugam
 
PDF
Spring Framework - Core
Dzmitry Naskou
 
PPSX
Spring - Part 1 - IoC, Di and Beans
Hitesh-Java
 
ODP
Spring User Guide
Muthuselvam RS
 
PDF
Spring Boot Interview Questions | Edureka
Edureka!
 
PPTX
Spring Boot
Jiayun Zhou
 
PPT
Spring ppt
Mumbai Academisc
 
PDF
Spring Boot
Pei-Tang Huang
 
PPTX
ASP.NET Core MVC + Web API with Overview
Shahed Chowdhuri
 
PPTX
Spring boot - an introduction
Jonathan Holloway
 
Spring boot
Gyanendra Yadav
 
Introduction to Spring Framework
Hùng Nguyễn Huy
 
Spring mvc
Pravin Pundge
 
Introduction to Spring Framework
Serhat Can
 
Introduction to Spring Boot
Purbarun Chakrabarti
 
Spring core module
Raj Tomar
 
Spring boot Introduction
Jeevesh Pandey
 
JPA and Hibernate
elliando dias
 
Spring Core
Pushan Bhattacharya
 
Java Hibernate Programming with Architecture Diagram and Example
kamal kotecha
 
Spring boot
Pradeep Shanmugam
 
Spring Framework - Core
Dzmitry Naskou
 
Spring - Part 1 - IoC, Di and Beans
Hitesh-Java
 
Spring User Guide
Muthuselvam RS
 
Spring Boot Interview Questions | Edureka
Edureka!
 
Spring Boot
Jiayun Zhou
 
Spring ppt
Mumbai Academisc
 
Spring Boot
Pei-Tang Huang
 
ASP.NET Core MVC + Web API with Overview
Shahed Chowdhuri
 
Spring boot - an introduction
Jonathan Holloway
 

Similar to Spring framework Introduction (20)

PPTX
Spring framework Introduction
Anuj Singh Rajput
 
PPTX
Spring framework-tutorial
vinayiqbusiness
 
DOCX
Spring notes
Rajeev Uppala
 
ODT
Spring framework
Shivi Kashyap
 
PPTX
Spring framework
Kani Selvam
 
PDF
스프링 프레임워크
Yoonki Chang
 
PDF
Spring framework
vietduc17
 
PDF
Spring Framework Tutorial | VirtualNuggets
Virtual Nuggets
 
PPTX
Spring Basics
ThirupathiReddy Vajjala
 
PPTX
Java spring ppt
natashasweety7
 
PPTX
Springs_Training
KAMALA KOLLURI
 
PPTX
Spring (1)
Aneega
 
PPTX
spring framework ppt by Rohit malav
Rohit malav
 
PPTX
Java Spring Framework
Mehul Jariwala
 
DOCX
Month 3 report
PRIYANKA FNU
 
PPTX
Introduction to Spring Framework
ASG
 
PPTX
Spring framework
Sonal Poddar
 
PPTX
Introduction to Spring Framework
Dineesha Suraweera
 
PPTX
Learn Spring Boot With Bisky - Intoduction
MarshallChabaga
 
PPTX
Spring
komalpreethi
 
Spring framework Introduction
Anuj Singh Rajput
 
Spring framework-tutorial
vinayiqbusiness
 
Spring notes
Rajeev Uppala
 
Spring framework
Shivi Kashyap
 
Spring framework
Kani Selvam
 
스프링 프레임워크
Yoonki Chang
 
Spring framework
vietduc17
 
Spring Framework Tutorial | VirtualNuggets
Virtual Nuggets
 
Java spring ppt
natashasweety7
 
Springs_Training
KAMALA KOLLURI
 
Spring (1)
Aneega
 
spring framework ppt by Rohit malav
Rohit malav
 
Java Spring Framework
Mehul Jariwala
 
Month 3 report
PRIYANKA FNU
 
Introduction to Spring Framework
ASG
 
Spring framework
Sonal Poddar
 
Introduction to Spring Framework
Dineesha Suraweera
 
Learn Spring Boot With Bisky - Intoduction
MarshallChabaga
 
Spring
komalpreethi
 
Ad

More from Anuj Singh Rajput (20)

PPTX
Web technology
Anuj Singh Rajput
 
PPTX
Java script
Anuj Singh Rajput
 
PPTX
Html (hypertext markup language)
Anuj Singh Rajput
 
PPTX
Bootstrap
Anuj Singh Rajput
 
PPTX
Jsp session 13
Anuj Singh Rajput
 
PPTX
Jsp session 12
Anuj Singh Rajput
 
PPTX
Jsp session 11
Anuj Singh Rajput
 
PPTX
Jsp session 10
Anuj Singh Rajput
 
PPTX
Jsp session 9
Anuj Singh Rajput
 
PPTX
Jsp session 8
Anuj Singh Rajput
 
PPTX
Jsp session 7
Anuj Singh Rajput
 
PPTX
Jsp session 6
Anuj Singh Rajput
 
PPTX
Jsp session 5
Anuj Singh Rajput
 
PPTX
Jsp session 4
Anuj Singh Rajput
 
PPTX
Jsp session 3
Anuj Singh Rajput
 
PPTX
Jsp session 2
Anuj Singh Rajput
 
PPTX
Jsp session 1
Anuj Singh Rajput
 
PPTX
Servlet session 14
Anuj Singh Rajput
 
PPTX
Servlet session 13
Anuj Singh Rajput
 
Web technology
Anuj Singh Rajput
 
Java script
Anuj Singh Rajput
 
Html (hypertext markup language)
Anuj Singh Rajput
 
Jsp session 13
Anuj Singh Rajput
 
Jsp session 12
Anuj Singh Rajput
 
Jsp session 11
Anuj Singh Rajput
 
Jsp session 10
Anuj Singh Rajput
 
Jsp session 9
Anuj Singh Rajput
 
Jsp session 8
Anuj Singh Rajput
 
Jsp session 7
Anuj Singh Rajput
 
Jsp session 6
Anuj Singh Rajput
 
Jsp session 5
Anuj Singh Rajput
 
Jsp session 4
Anuj Singh Rajput
 
Jsp session 3
Anuj Singh Rajput
 
Jsp session 2
Anuj Singh Rajput
 
Jsp session 1
Anuj Singh Rajput
 
Servlet session 14
Anuj Singh Rajput
 
Servlet session 13
Anuj Singh Rajput
 
Ad

Recently uploaded (20)

PDF
Stokey: A Jewish Village by Rachel Kolsky
History of Stoke Newington
 
PPT
Talk on Critical Theory, Part II, Philosophy of Social Sciences
Soraj Hongladarom
 
PPTX
grade 5 lesson matatag ENGLISH 5_Q1_PPT_WEEK4.pptx
SireQuinn
 
PDF
Biological Bilingual Glossary Hindi and English Medium
World of Wisdom
 
PDF
ARAL_Orientation_Day-2-Sessions_ARAL-Readung ARAL-Mathematics ARAL-Sciencev2.pdf
JoelVilloso1
 
PPTX
SPINA BIFIDA: NURSING MANAGEMENT .pptx
PRADEEP ABOTHU
 
PDF
Dimensions of Societal Planning in Commonism
StefanMz
 
PDF
The History of Phone Numbers in Stoke Newington by Billy Thomas
History of Stoke Newington
 
PDF
Reconstruct, Restore, Reimagine: New Perspectives on Stoke Newington’s Histor...
History of Stoke Newington
 
PDF
Exploring the Different Types of Experimental Research
Thelma Villaflores
 
PPTX
How to Handle Salesperson Commision in Odoo 18 Sales
Celine George
 
PDF
The Constitution Review Committee (CRC) has released an updated schedule for ...
nservice241
 
PPT
Talk on Critical Theory, Part One, Philosophy of Social Sciences
Soraj Hongladarom
 
PDF
DIGESTION OF CARBOHYDRATES,PROTEINS,LIPIDS
raviralanaresh2
 
PPTX
MENINGITIS: NURSING MANAGEMENT, BACTERIAL MENINGITIS, VIRAL MENINGITIS.pptx
PRADEEP ABOTHU
 
PPTX
ASRB NET 2023 PREVIOUS YEAR QUESTION PAPER GENETICS AND PLANT BREEDING BY SAT...
Krashi Coaching
 
PDF
Women's Health: Essential Tips for Every Stage.pdf
Iftikhar Ahmed
 
PPTX
Growth and development and milestones, factors
BHUVANESHWARI BADIGER
 
PPTX
How to Set Up Tags in Odoo 18 - Odoo Slides
Celine George
 
PPTX
Cultivation practice of Litchi in Nepal.pptx
UmeshTimilsina1
 
Stokey: A Jewish Village by Rachel Kolsky
History of Stoke Newington
 
Talk on Critical Theory, Part II, Philosophy of Social Sciences
Soraj Hongladarom
 
grade 5 lesson matatag ENGLISH 5_Q1_PPT_WEEK4.pptx
SireQuinn
 
Biological Bilingual Glossary Hindi and English Medium
World of Wisdom
 
ARAL_Orientation_Day-2-Sessions_ARAL-Readung ARAL-Mathematics ARAL-Sciencev2.pdf
JoelVilloso1
 
SPINA BIFIDA: NURSING MANAGEMENT .pptx
PRADEEP ABOTHU
 
Dimensions of Societal Planning in Commonism
StefanMz
 
The History of Phone Numbers in Stoke Newington by Billy Thomas
History of Stoke Newington
 
Reconstruct, Restore, Reimagine: New Perspectives on Stoke Newington’s Histor...
History of Stoke Newington
 
Exploring the Different Types of Experimental Research
Thelma Villaflores
 
How to Handle Salesperson Commision in Odoo 18 Sales
Celine George
 
The Constitution Review Committee (CRC) has released an updated schedule for ...
nservice241
 
Talk on Critical Theory, Part One, Philosophy of Social Sciences
Soraj Hongladarom
 
DIGESTION OF CARBOHYDRATES,PROTEINS,LIPIDS
raviralanaresh2
 
MENINGITIS: NURSING MANAGEMENT, BACTERIAL MENINGITIS, VIRAL MENINGITIS.pptx
PRADEEP ABOTHU
 
ASRB NET 2023 PREVIOUS YEAR QUESTION PAPER GENETICS AND PLANT BREEDING BY SAT...
Krashi Coaching
 
Women's Health: Essential Tips for Every Stage.pdf
Iftikhar Ahmed
 
Growth and development and milestones, factors
BHUVANESHWARI BADIGER
 
How to Set Up Tags in Odoo 18 - Odoo Slides
Celine George
 
Cultivation practice of Litchi in Nepal.pptx
UmeshTimilsina1
 

Spring framework Introduction

  • 2. What is Spring ? 1. Spring Framework is a open source Java Platform that provides comprehensive infrastructure support for developing robust Java application very easily and rapidly. 2. Spring framework was developed by Rod Johnson and was first released in 2003 in Spring Organization now Pivotal. 3. Earlier name of Spring Framework was Interface21 later changed to Spring based on Spring season. 4. Spring Framework is replacement of EJB’s (Enterprise Java Beans) because of heavy weight of EJB’s
  • 3. Why Spring ? 1. Spring is the most popular application development framework for enterprise Java. Millions of developers around the world use Spring Framework to create high performing, easily testable, and reusable code. 2. Spring is lightweight when it comes to size and transparency. The basic version of Spring framework is around 2MB. 3. The core features of the Spring Framework can be used in developing any Java application, but there are extensions for building web applications on top of the Java EE platform. 4. Spring framework targets to make J2EE development easier to use and promotes good programming practices by enabling a POJO-based programming model.
  • 4. Advantages of Spring 1. Lightweight - Spring framework is lightweight because of its POJO implementation.The Spring framework doesn’t force any programmer to inherit any class or implements any interface. That is why it is said non-invasive, Enable you to write powerful, scalable applications using POJO. 2. Easy to develop J2EE application - The Dependency Injection feature of Spring Framework and it support to various frameworks makes the easy development of JavaEE application. 3. Easy to test - The Dependency Injection makes easier to test the application. The EJB or Struts application require server to run the application but Spring framework doesn't require server.
  • 5. 1. Loose Coupling - The Spring applications are loosely coupled because of dependency injection and handles injecting dependent components without a component knowing where they came from (IoC). 2. Powerful abstraction - It provides powerful abstraction to JavaEE specifications such as JDBC. 3. Declarative support - It provides declarative support for caching, validation, transactions and formatting. 4. Portable - can use server - side in web/ejb app, client-side in swing app, business logic is completely portable. 5. Lifecycle - Responsible for managing all your application components, particularly those in the middle tier container sees components through well-defined lifecycle: init(), destroy()
  • 6. Modules of the Spring Framework 1. Core - Inversion of Control (IoC) and Dependency Injection. 2. AOP - These modules support aspect oriented programming implementation where you can use Advices, Pointcuts etc. to decouple the code. 3. DAO - Data Access Object support, transaction management, JDBC-abstraction 4. ORM - Object Relational Mapping data access, integration layers for Hibernate 5. MVC - Model-View-Controller implementation for web applications 6. Expression Language - It is an extension to the EL defined in JSP. It provides support to setting and getting property values, method invocation, accessing collections and indexers, named variables.
  • 7. IOC and Dependency Injection 1. Dependency Injection is the main functionality provided by Spring IOC (Inversion of Control). 2. The Spring-Core module is responsible for injecting dependencies through either Constructor or Setter methods in POJO class. 3. Dependency Injection in Spring also ensures loose-coupling between the classes. Need for Dependency Injection: 1. Spring IOC resolves dependencies with Dependency Injection, which makes the code easier to test and reuse. 2. Loose coupling between classes can be possible by defining interfaces for common functionality and the injector will instantiate the objects of required implementation.
  • 8. Example Tightly Coupling - (without IOC) class Employee{ Address address; Employee() {address=new Address(“xyz street”, ”Lucknow”, ”UP”); }} One class object is created in another class in tight coupling.Leads to a.Stop server b.Recomplie c.Create jar and war file d.Redeploy e.Restart the server.
  • 9. Loose Coupling 1. with IOC (Constructor Injection) class Employee{ Address address; Employee(Address address) {this.address=address;} } 2. with IOC (Setter Injection) class Employee{ Address address; public void setAddress(Address address) {this.address=address;} } No need to stop the existing component, in real time it is better.
  • 10. Spring Architecture (Very loosely coupled, components widely reusable) and separately packaged.
  • 11. 1. Spring allows to decouple software layers by injecting a component’s dependencies at runtime rather than having them declared at compile time via importing and instantiating classes. 2. Spring provides integration for J2EE services such as EJB, JDBC, JNDI, JMS, JTA. It also integrates several popular ORM toolkits such as Hibernate and JDO and assorted other services as well. 3. One of the highly touted 4. Spring is built on the principle of unchecked exception handling. This also reduces code dependencies between layers. Spring provides a granular exception hierarchy for data access operations and maps JDBC, EJB, and ORM exceptions to Spring exceptions so that applications can get better information about the error condition.
  • 12. Flow Control in Spring
  • 13. How to Start Using Spring 1. create the class 2. create the xml file to provide the values 3. create the test class 4. Load the spring jar files 5. Run the test class
  • 14. 1. CLASS FILE - POJO (PLAIN OLD JAVA OBJECT)
  • 15. 2. TEST FILE - DAO (DATA ACCESS OBJECT)
  • 16. 3. BEAN FILE - XML
  • 17. 4. Load the jar files required for spring framework There are mainly three jar files required to run this application. 1. org.springframework.core-3.0.1.RELEASE-A 2. com.springsource.org.apache.commons.logging-1.1.1 3. org.springframework.beans-3.0.1.RELEASE-A 5. Run the TEST FILE
  • 18. Containers in Spring 1. Core Container (slower) a. It is called Lazy Container. b. It create object on demand one by one. c. It will create the object when the bean file is loaded. ClassPathResource res=new ClassPathResource(“Spring.xml”); XmlBeanFactory fact=new XmlBeanFactory(res); fact.getBean(“abc”); 2. J2EE Container (faster) a. It is called Eager Container. b. It create all object at once. c. It cerate the object as soon as object of ApplicationContext is made. ApplicationContext con=new ClassPathXmlApplicationContext(“Spring.xml”);
  • 19. Bean File • Typical java bean with a unique id • In spring there are basically two types 1. Singleton One instance of the bean created and referenced each time it is requested <bean class=“bean.Test” id=“t” scope=“singleton”> One object for all caller. 2. Prototype (non-singleton) <bean class=“bean.Test” id=“t” scope=“prototype”> multiple object i.e. one one object for each caller.