SlideShare a Scribd company logo
Spring Framework
Dineesha Suraweera
What is a framework ?
framework is a universal, reusable software environment that provides
particular functionality as part of a larger software platform to facilitate
development of software applications, products and solutions.
Software frameworks may include
support programs
compilers
code libraries
tool sets 2
How to separate framework from library ….
❏Inversion Control: In a framework, unlike in libraries the overall program's flow control is not
dictated by the caller, but by the framework.
❏default behavior
❏extensibility: can be extended by the user usually by selective overriding or specialized by user
code to provide specific functionality.
❏non-modifiable framework code: The framework code, in general, is not supposed to be
modified, while accepting user-implemented extensions.
3
Spring framework
Spring is the most popular application development framework for
enterprise Java.
open source Java platform
initially written by Rod Johnson and was first released under the Apache 2.0
license in June 2003.
lightweight when it comes to size and transparency.
4
Where to use ?
can be used in developing any Java application, but there are extensions for
building web applications on top of the Java EE platform.
Spring framework targets to make J2EE development easier to use and promote
good programming practice by enabling a POJO-based programming model.
5
Benefits of spring..
Spring is organized in a modular fashion
makes use of technologies like several ORM frameworks, logging
frameworks, JEE, Quartz and JDK timers, other view technologies
Testing an application written with Spring is simple
Spring's web framework is a well-designed web MVC framework
provides a convenient API to translate technology-specific exceptions into
consistent, unchecked exceptions
6
Architecture
7
Description of architecture
Core Container
Core provides the fundamental parts of the framework, including the IoC and Dependency
Injection features.
Bean provides BeanFactory which is a sophisticated implementation of the factory pattern.
Context builds on the solid base provided by the Core and Beans modules and it is a medium to
access any objects defined and configured.
SpEL module provides a powerful expression language for querying and manipulating an object
graph at runtime.
8
Data Access/Integration
JDBC provides a JDBC-abstraction layer that removes the need to do tedious JDBC related coding.
ORM provides integration layers for popular object-relational mapping APIs, including JPA, JDO,
Hibernate, and iBatis.
OXM provides an abstraction layer that supports Object/XML mapping implementations for JAXB,
Castor, XMLBeans, JiBX and XStream.
JMS contains features for producing and consuming messages.
Transaction supports programmatic and declarative transaction management for classes that
implement special interfaces and for all your POJOs.
9
Web
Web provides basic web-oriented integration features such as multipart file-upload functionality
and the initialization of the IoC container using servlet listeners and a web-oriented application
context.
Web-MVC contains Spring's model-view-controller (MVC) implementation for web applications.
Web-Socket provides support for WebSocket-based, two-way communication between client and
server in web applications.
Web-Portlet provides the MVC implementation to be used in a portlet environment and mirrors
the functionality of Web-Servlet module.
10
pre-requisites
Java Development Kit (JDK)
Apache Common Logging API
http://commons.apache.org/proper/commons-logging/download_logging.cgi
Spring Framework Libraries
http://repo.spring.io/release/org/springframework/spring/
11
How to use
1. Create java project
1. Add required libraries
12
3. Create source files.
4. Create Bean configuration file
13
14
15
Spring with maven
If you are using Maven for dependency management you don’t even need to supply the logging
dependency explicitly.
To create an application context and use dependency injection to configure an application
16
IoC Containers
Core of the Spring Framework
The container will create the objects, wire them together, configure them, and
manage their complete lifecycle from creation till destruction.
17
uses dependency injection (DI) to manage the components that make up an
application(spring Beans)
Spring BeanFactory Container
simplest container providing basic support for DI and defined by the
org.springframework.beans.factory.BeanFactory interface. The BeanFactory and related interfaces, such as
BeanFactoryAware, InitializingBean, DisposableBean, are still present in Spring for the purposes of backward
compatibility with the large number of third-party frameworks that integrate with Spring.
Spring ApplicationContext Container
adds more enterprise-specific functionality such as the ability to resolve textual messages from a properties file
and the ability to publish application events to interested event listeners. This container is defined by the
org.springframework.context.ApplicationContext interface.
18
Benefits of IoC/DI
Reduced Dependencies
Reduced Dependency Carrying
More Reusable Code
More Testable Code
More Readable Code
19
Bean Definition
A bean is an object that is instantiated, assembled, and otherwise managed by
a Spring IoC container.
The bean definition contains the information called configuration metadata
which is needed for the container to know the followings
How to create a bean
Bean's lifecycle details
Bean's dependencies
20
Spring Configuration Metadata
There are three important methods to provide configuration metadata to the
Spring Container
XML based configuration file.
Annotation-based configuration
Java-based configuration
21
22
Annotation based configuration
To describe a bean wiring,move the bean configuration into the component
class itself by using annotations on the relevant class, method, or field
declaration.
Annotation wiring is not turned on in the Spring container by default
23
Basic annotations
@Required
The @Required annotation applies to bean property setter methods.
@Autowired
The @Autowired annotation can apply to bean property setter methods, non-setter methods, constructor and
properties.
@Qualifier
The @Qualifier annotation along with @Autowired can be used to remove the confusion by specifying which exact
bean will be wired.
JSR-250 Annotations
Spring supports JSR-250 based annotations which include @Resource, @PostConstruct and @PreDestroy
annotations. 24
Java based configuration
Java based configuration option enables you to write most of your Spring
configuration without XML but with the help of few Java-based annotations
@Configuration
class can be used by the Spring IoC container as a source of bean definitions
@Bean Annotations
return an object that should be registered as a bean in the Spring application context.
@Import Annotation
25
Dependency Injection
The Dependency Injection is a design pattern that removes the dependency of
the programs. In such case we provide the information from the external
source such as XML file. It makes our code loosely coupled and easier for
testing.
Spring framework provides two ways to inject dependency
By Constructor
By Setter method
26
In such case, instance of Address class is provided by external source such as
XML file either by constructor or setter method.
27
Beans auto-wiring
Enables you to inject the object dependency implicitly. It internally uses setter or constructor
injection.
Autowiring can't be used to inject primitive and string values. It works with reference only.
28
AOP with Spring Framework
Aspect Oriented Programming entails breaking down program logic into
distinct parts.(like logging, auditing, declarative transactions, security, and
caching etc)
Spring AOP module provides interceptors to intercept an application, when a
method is executed, you can add extra functionality before or after the
method execution.
29
Demo
30
Other Spring projects
Spring Cloud
Spring Data
Spring Security
Spring Social
Spring Mobile
Spring Session
Spring Shell
31
Thank You!
32

More Related Content

What's hot (20)

PPTX
Spring Boot
Jiayun Zhou
 
PPTX
Spring Framework
tola99
 
PPSX
Spring - Part 1 - IoC, Di and Beans
Hitesh-Java
 
PPTX
Threading in C#
Medhat Dawoud
 
PPTX
.Net Core 1.0 vs .NET Framework
Wyn B. Van Devanter
 
PDF
Mongo DB
Edureka!
 
PDF
Spring annotation
Rajiv Srivastava
 
PDF
Introduction to Spring Framework
Hùng Nguyễn Huy
 
PPTX
Java Spring Framework
Mehul Jariwala
 
PPTX
Les dessous du framework spring
Antoine Rey
 
PPT
Spring ppt
Mumbai Academisc
 
PPTX
Spring boot Introduction
Jeevesh Pandey
 
PDF
Spring MVC
Aaron Schram
 
PPTX
JPA For Beginner's
NarayanaMurthy Ganashree
 
PDF
Spring Boot
koppenolski
 
PDF
introduction to Vue.js 3
ArezooKmn
 
PDF
Reactjs Basics
Hamid Ghorbani
 
PPTX
React-JS Component Life-cycle Methods
ANKUSH CHAVAN
 
PPT
Spring mvc
Lhouceine OUHAMZA
 
Spring Boot
Jiayun Zhou
 
Spring Framework
tola99
 
Spring - Part 1 - IoC, Di and Beans
Hitesh-Java
 
Threading in C#
Medhat Dawoud
 
.Net Core 1.0 vs .NET Framework
Wyn B. Van Devanter
 
Mongo DB
Edureka!
 
Spring annotation
Rajiv Srivastava
 
Introduction to Spring Framework
Hùng Nguyễn Huy
 
Java Spring Framework
Mehul Jariwala
 
Les dessous du framework spring
Antoine Rey
 
Spring ppt
Mumbai Academisc
 
Spring boot Introduction
Jeevesh Pandey
 
Spring MVC
Aaron Schram
 
JPA For Beginner's
NarayanaMurthy Ganashree
 
Spring Boot
koppenolski
 
introduction to Vue.js 3
ArezooKmn
 
Reactjs Basics
Hamid Ghorbani
 
React-JS Component Life-cycle Methods
ANKUSH CHAVAN
 
Spring mvc
Lhouceine OUHAMZA
 

Viewers also liked (20)

PDF
Getting Started with Spring Framework
Edureka!
 
PPTX
Springs
sammydude10
 
PPT
Presentation Spring
Nathaniel Richand
 
PDF
Spring framework core
Taemon Piya-Lumyong
 
PDF
Spring MVC Annotations
Jordan Silva
 
PDF
Spring 4 - A&BP CC
JWORKS powered by Ordina
 
PDF
Spring 4 Web App
Rossen Stoyanchev
 
PPTX
Next stop: Spring 4
Oleg Tsal-Tsalko
 
PDF
Spring MVC - The Basics
Ilio Catallo
 
PPT
Presentation Spring, Spring MVC
Nathaniel Richand
 
PPT
Spring MVC Basics
Bozhidar Bozhanov
 
PPT
Spring MVC 3.0 Framework
Ravi Kant Soni ([email protected])
 
PDF
Spring tutorial
Sanjoy Kumer Deb
 
PPTX
Spring Framework Essentials
Edward Goikhman
 
PPTX
Spring framework in depth
Vinay Kumar
 
PDF
Spring core module
Raj Tomar
 
PPTX
Sectors of indian economy
madan kumar
 
PPTX
nationalism movement in Indochina
madan kumar
 
PPTX
Spock
Evgeny Borisov
 
PPTX
Physicalfeaturesofindia
madan kumar
 
Getting Started with Spring Framework
Edureka!
 
Springs
sammydude10
 
Presentation Spring
Nathaniel Richand
 
Spring framework core
Taemon Piya-Lumyong
 
Spring MVC Annotations
Jordan Silva
 
Spring 4 - A&BP CC
JWORKS powered by Ordina
 
Spring 4 Web App
Rossen Stoyanchev
 
Next stop: Spring 4
Oleg Tsal-Tsalko
 
Spring MVC - The Basics
Ilio Catallo
 
Presentation Spring, Spring MVC
Nathaniel Richand
 
Spring MVC Basics
Bozhidar Bozhanov
 
Spring MVC 3.0 Framework
Ravi Kant Soni ([email protected])
 
Spring tutorial
Sanjoy Kumer Deb
 
Spring Framework Essentials
Edward Goikhman
 
Spring framework in depth
Vinay Kumar
 
Spring core module
Raj Tomar
 
Sectors of indian economy
madan kumar
 
nationalism movement in Indochina
madan kumar
 
Physicalfeaturesofindia
madan kumar
 
Ad

Similar to Introduction to Spring Framework (20)

PDF
Spring Framework Tutorial | VirtualNuggets
Virtual Nuggets
 
PPTX
Spring Framework Rohit
Rohit Prabhakar
 
PPT
Spring introduction
Manav Prasad
 
PPTX
Spring (1)
Aneega
 
ODT
Spring framework
Shivi Kashyap
 
PPT
Spring
Prashant Kumar
 
PPTX
Spring framework
Kani Selvam
 
PPT
Spring Framework
Preetam Palwe
 
PPTX
Spring framework Introduction
Anuj Singh Rajput
 
PDF
Spring presentecion isil
Willy Aguirre
 
PDF
Spring presentecion isil
Willy Aguirre
 
PPTX
Spring
komalpreethi
 
PPTX
Introduction to Spring Framework
ASG
 
PDF
Spring 2
Aruvi Thottlan
 
PPTX
1. Spring intro IoC
ASG
 
PPT
Spring - a framework written by developers
MarcioSoaresPereira1
 
PPTX
Introduction to Spring sec1.pptx
NourhanTarek23
 
PPT
Hybernat and structs, spring classes in mumbai
Vibrant Technologies & Computers
 
PDF
Spring framework Introduction
Anuj Singh Rajput
 
PPTX
unit_1_spring_1.pptxfgfgggjffgggddddgggg
zmulani8
 
Spring Framework Tutorial | VirtualNuggets
Virtual Nuggets
 
Spring Framework Rohit
Rohit Prabhakar
 
Spring introduction
Manav Prasad
 
Spring (1)
Aneega
 
Spring framework
Shivi Kashyap
 
Spring framework
Kani Selvam
 
Spring Framework
Preetam Palwe
 
Spring framework Introduction
Anuj Singh Rajput
 
Spring presentecion isil
Willy Aguirre
 
Spring presentecion isil
Willy Aguirre
 
Spring
komalpreethi
 
Introduction to Spring Framework
ASG
 
Spring 2
Aruvi Thottlan
 
1. Spring intro IoC
ASG
 
Spring - a framework written by developers
MarcioSoaresPereira1
 
Introduction to Spring sec1.pptx
NourhanTarek23
 
Hybernat and structs, spring classes in mumbai
Vibrant Technologies & Computers
 
Spring framework Introduction
Anuj Singh Rajput
 
unit_1_spring_1.pptxfgfgggjffgggddddgggg
zmulani8
 
Ad

Recently uploaded (20)

PPTX
Farrell__10e_ch04_PowerPoint.pptx Programming Logic and Design slides
bashnahara11
 
PPT
Brief History of Python by Learning Python in three hours
adanechb21
 
PDF
Enhancing Healthcare RPM Platforms with Contextual AI Integration
Cadabra Studio
 
PPT
Why Reliable Server Maintenance Service in New York is Crucial for Your Business
Sam Vohra
 
PDF
WatchTraderHub - Watch Dealer software with inventory management and multi-ch...
WatchDealer Pavel
 
PDF
Generating Union types w/ Static Analysis
K. Matthew Dupree
 
PPT
Activate_Methodology_Summary presentatio
annapureddyn
 
PPTX
Presentation about variables and constant.pptx
kr2589474
 
PPTX
TRAVEL APIs | WHITE LABEL TRAVEL API | TOP TRAVEL APIs
philipnathen82
 
PDF
advancepresentationskillshdhdhhdhdhdhhfhf
jasmenrojas249
 
PDF
What companies do with Pharo (ESUG 2025)
ESUG
 
PDF
Salesforce Implementation Services Provider.pdf
VALiNTRY360
 
PDF
Applitools Platform Pulse: What's New and What's Coming - July 2025
Applitools
 
PDF
Supabase Meetup: Build in a weekend, scale to millions
Carlo Gilmar Padilla Santana
 
PDF
Download iTop VPN Free 6.1.0.5882 Crack Full Activated Pre Latest 2025
imang66g
 
PDF
On Software Engineers' Productivity - Beyond Misleading Metrics
Romén Rodríguez-Gil
 
PDF
Protecting the Digital World Cyber Securit
dnthakkar16
 
PDF
SAP GUI Installation Guide for Windows | Step-by-Step Setup for SAP Access
SAP Vista, an A L T Z E N Company
 
PDF
10 posting ideas for community engagement with AI prompts
Pankaj Taneja
 
PPTX
Contractor Management Platform and Software Solution for Compliance
SHEQ Network Limited
 
Farrell__10e_ch04_PowerPoint.pptx Programming Logic and Design slides
bashnahara11
 
Brief History of Python by Learning Python in three hours
adanechb21
 
Enhancing Healthcare RPM Platforms with Contextual AI Integration
Cadabra Studio
 
Why Reliable Server Maintenance Service in New York is Crucial for Your Business
Sam Vohra
 
WatchTraderHub - Watch Dealer software with inventory management and multi-ch...
WatchDealer Pavel
 
Generating Union types w/ Static Analysis
K. Matthew Dupree
 
Activate_Methodology_Summary presentatio
annapureddyn
 
Presentation about variables and constant.pptx
kr2589474
 
TRAVEL APIs | WHITE LABEL TRAVEL API | TOP TRAVEL APIs
philipnathen82
 
advancepresentationskillshdhdhhdhdhdhhfhf
jasmenrojas249
 
What companies do with Pharo (ESUG 2025)
ESUG
 
Salesforce Implementation Services Provider.pdf
VALiNTRY360
 
Applitools Platform Pulse: What's New and What's Coming - July 2025
Applitools
 
Supabase Meetup: Build in a weekend, scale to millions
Carlo Gilmar Padilla Santana
 
Download iTop VPN Free 6.1.0.5882 Crack Full Activated Pre Latest 2025
imang66g
 
On Software Engineers' Productivity - Beyond Misleading Metrics
Romén Rodríguez-Gil
 
Protecting the Digital World Cyber Securit
dnthakkar16
 
SAP GUI Installation Guide for Windows | Step-by-Step Setup for SAP Access
SAP Vista, an A L T Z E N Company
 
10 posting ideas for community engagement with AI prompts
Pankaj Taneja
 
Contractor Management Platform and Software Solution for Compliance
SHEQ Network Limited
 

Introduction to Spring Framework

  • 2. What is a framework ? framework is a universal, reusable software environment that provides particular functionality as part of a larger software platform to facilitate development of software applications, products and solutions. Software frameworks may include support programs compilers code libraries tool sets 2
  • 3. How to separate framework from library …. ❏Inversion Control: In a framework, unlike in libraries the overall program's flow control is not dictated by the caller, but by the framework. ❏default behavior ❏extensibility: can be extended by the user usually by selective overriding or specialized by user code to provide specific functionality. ❏non-modifiable framework code: The framework code, in general, is not supposed to be modified, while accepting user-implemented extensions. 3
  • 4. Spring framework Spring is the most popular application development framework for enterprise Java. open source Java platform initially written by Rod Johnson and was first released under the Apache 2.0 license in June 2003. lightweight when it comes to size and transparency. 4
  • 5. Where to use ? can be used in developing any Java application, but there are extensions for building web applications on top of the Java EE platform. Spring framework targets to make J2EE development easier to use and promote good programming practice by enabling a POJO-based programming model. 5
  • 6. Benefits of spring.. Spring is organized in a modular fashion makes use of technologies like several ORM frameworks, logging frameworks, JEE, Quartz and JDK timers, other view technologies Testing an application written with Spring is simple Spring's web framework is a well-designed web MVC framework provides a convenient API to translate technology-specific exceptions into consistent, unchecked exceptions 6
  • 8. Description of architecture Core Container Core provides the fundamental parts of the framework, including the IoC and Dependency Injection features. Bean provides BeanFactory which is a sophisticated implementation of the factory pattern. Context builds on the solid base provided by the Core and Beans modules and it is a medium to access any objects defined and configured. SpEL module provides a powerful expression language for querying and manipulating an object graph at runtime. 8
  • 9. Data Access/Integration JDBC provides a JDBC-abstraction layer that removes the need to do tedious JDBC related coding. ORM provides integration layers for popular object-relational mapping APIs, including JPA, JDO, Hibernate, and iBatis. OXM provides an abstraction layer that supports Object/XML mapping implementations for JAXB, Castor, XMLBeans, JiBX and XStream. JMS contains features for producing and consuming messages. Transaction supports programmatic and declarative transaction management for classes that implement special interfaces and for all your POJOs. 9
  • 10. Web Web provides basic web-oriented integration features such as multipart file-upload functionality and the initialization of the IoC container using servlet listeners and a web-oriented application context. Web-MVC contains Spring's model-view-controller (MVC) implementation for web applications. Web-Socket provides support for WebSocket-based, two-way communication between client and server in web applications. Web-Portlet provides the MVC implementation to be used in a portlet environment and mirrors the functionality of Web-Servlet module. 10
  • 11. pre-requisites Java Development Kit (JDK) Apache Common Logging API http://commons.apache.org/proper/commons-logging/download_logging.cgi Spring Framework Libraries http://repo.spring.io/release/org/springframework/spring/ 11
  • 12. How to use 1. Create java project 1. Add required libraries 12
  • 13. 3. Create source files. 4. Create Bean configuration file 13
  • 14. 14
  • 15. 15
  • 16. Spring with maven If you are using Maven for dependency management you don’t even need to supply the logging dependency explicitly. To create an application context and use dependency injection to configure an application 16
  • 17. IoC Containers Core of the Spring Framework The container will create the objects, wire them together, configure them, and manage their complete lifecycle from creation till destruction. 17
  • 18. uses dependency injection (DI) to manage the components that make up an application(spring Beans) Spring BeanFactory Container simplest container providing basic support for DI and defined by the org.springframework.beans.factory.BeanFactory interface. The BeanFactory and related interfaces, such as BeanFactoryAware, InitializingBean, DisposableBean, are still present in Spring for the purposes of backward compatibility with the large number of third-party frameworks that integrate with Spring. Spring ApplicationContext Container adds more enterprise-specific functionality such as the ability to resolve textual messages from a properties file and the ability to publish application events to interested event listeners. This container is defined by the org.springframework.context.ApplicationContext interface. 18
  • 19. Benefits of IoC/DI Reduced Dependencies Reduced Dependency Carrying More Reusable Code More Testable Code More Readable Code 19
  • 20. Bean Definition A bean is an object that is instantiated, assembled, and otherwise managed by a Spring IoC container. The bean definition contains the information called configuration metadata which is needed for the container to know the followings How to create a bean Bean's lifecycle details Bean's dependencies 20
  • 21. Spring Configuration Metadata There are three important methods to provide configuration metadata to the Spring Container XML based configuration file. Annotation-based configuration Java-based configuration 21
  • 22. 22
  • 23. Annotation based configuration To describe a bean wiring,move the bean configuration into the component class itself by using annotations on the relevant class, method, or field declaration. Annotation wiring is not turned on in the Spring container by default 23
  • 24. Basic annotations @Required The @Required annotation applies to bean property setter methods. @Autowired The @Autowired annotation can apply to bean property setter methods, non-setter methods, constructor and properties. @Qualifier The @Qualifier annotation along with @Autowired can be used to remove the confusion by specifying which exact bean will be wired. JSR-250 Annotations Spring supports JSR-250 based annotations which include @Resource, @PostConstruct and @PreDestroy annotations. 24
  • 25. Java based configuration Java based configuration option enables you to write most of your Spring configuration without XML but with the help of few Java-based annotations @Configuration class can be used by the Spring IoC container as a source of bean definitions @Bean Annotations return an object that should be registered as a bean in the Spring application context. @Import Annotation 25
  • 26. Dependency Injection The Dependency Injection is a design pattern that removes the dependency of the programs. In such case we provide the information from the external source such as XML file. It makes our code loosely coupled and easier for testing. Spring framework provides two ways to inject dependency By Constructor By Setter method 26
  • 27. In such case, instance of Address class is provided by external source such as XML file either by constructor or setter method. 27
  • 28. Beans auto-wiring Enables you to inject the object dependency implicitly. It internally uses setter or constructor injection. Autowiring can't be used to inject primitive and string values. It works with reference only. 28
  • 29. AOP with Spring Framework Aspect Oriented Programming entails breaking down program logic into distinct parts.(like logging, auditing, declarative transactions, security, and caching etc) Spring AOP module provides interceptors to intercept an application, when a method is executed, you can add extra functionality before or after the method execution. 29
  • 31. Other Spring projects Spring Cloud Spring Data Spring Security Spring Social Spring Mobile Spring Session Spring Shell 31