SlideShare a Scribd company logo
1 of 41
Spring Framework Overview
Who invented Spring Framework
• Rod Johnson
• Spring (previously known as SpringSource) was a software company
founded by Rod Johnson, who also created the Spring Framework, an
open-source application framework for enterprise Java applications.
What is the basic concept of Spring?
• Spring is considered to be a secure, low-cost and flexible
framework that improves coding efficiency and reduces
overall application development time through efficient use of
system resources.
• Spring removes tedious configuration work so that developers
can focus on writing business logic
What is Spring used for?
• It helps application developers to perform the following functions:4
• Create a Java method that runs in a database transaction with no
help from transaction APIs.
• Create a local Java method that defines a remote procedure with no
help from remote APIs.
How to use Spring Framework?
• Create the Bean. java class.
• Create a XML/ configuration file.
• Create the main class.
• Load the required jar files.
• Run the application.
Why to Learn Spring?
• Spring is the application development framework for enterprise Java.
• to create high performing, easily testable, and reusable code.
• Spring framework is an open source Java platform. It was initially written by Rod
Johnson and was first released under the Apache 2.0 license in June 2003.
• Spring is lightweight when it comes to size and transparency. The basic version of
Spring framework is around 2MB.
• Spring framework targets to make J2EE development easier to use and promotes
good programming practices by enabling a POJO-based programming model.
• Plain old Java object (POJO) is a class definition
What is POJO and why it is used?
•POJO stands for Plain Old Java Object.
•It is used to describe a Java class that follows simple
conventions and does not depend on any specific
frameworks or libraries.
•A POJO typically contains private fields with corresponding
getter and setter methods, and it may also include additional
methods for behaviour.
Differences Between POJO and Java beans
• POJO can have other than private fields whereas Java beans
can only have private fields.
• POJO may or may not have a constructor whereas Java
beans should have a no-argument constructor.
public class test implements Serializable
{
private String a;
public test(){}
public String getA()
{return a;}
public void setA(String a)
{this.a=a;}
}
Example java Bean & POJO
Applications / benefits of Spring
• POJO Based - Spring enables developers to develop enterprise-class
applications using POJOs.
• The benefit of using only POJOs is that you do not need an EJB
container product such as an application server but you have the
option of using only a robust servlet container such as Tomcat or
some commercial product.
• Modular - Spring is organized in a modular fashion. Even though the
number of packages and classes are substantial.
Applications / benefits of Spring
• Integration with existing frameworks
• Testablity - Testing an application written with Spring is simple
because. environment-dependent code is moved into this
framework
• By using JavaBeanstyle POJOs, it becomes easier to use dependency
injection for injecting test data.
• Web MVC - which provides a great alternative to web frameworks
such as Struts or other over-engineered or less popular web
frameworks.
Applications / benefits of Spring
• Central Exception Handling - Spring provides a convenient API to translate
technology-specific exceptions (thrown by JDBC, Hibernate, or JDO, for
example) into consistent, unchecked exceptions.
• Lightweight - Lightweight IoC containers tend to be lightweight, especially
when compared to EJB containers, for example. This is beneficial for
developing and deploying applications on computers with limited memory
and CPU resources.
• Transaction management - Spring provides a consistent transaction
management interface that can scale down to a local transaction (using a
single database, for example) and scale up to global transactions (using JTA,
for example).
Spring's Inversion of Control (IoC) container
• It is responsible for instantiating, configuring
and assembling objects known as beans, as well
as managing their life cycles
Dependency Injection (DI)
• Dependency Injection (DI) is a design pattern used to implement IoC.
• It allows the creation of dependent objects outside of a class and
provides those objects to a class through different ways.
• It removes the dependency of the programs. In such case we provide
the information from the external source such as XML file.
• It makes code loosely coupled and easier for testing.
• Using DI, we move the creation and binding of the dependent
objects outside of the class that depends on them.
The Dependency Injection pattern involves 3
types of classes.
• Client Class: The client class (dependent class) is a class which
depends on the service class
• Service Class: The service class (dependency) is a class that provides
service to the client class.
• Injector Class: The injector class injects the service class object into
the client class.
• The following figure illustrates the relationship between these
classes:
Types of Dependency Injection
• the injector class injects the service (dependency) to the client
(dependent).
• The injector class injects dependencies broadly in three ways:
• through a constructor,
• through a property, or
• through a method.
class Employee{
Address address;
Employee(Address address){
this.address=address;
}
public void setAddress(Address address){
this.address=address;
}
}
Manual change
External code
What is difference between jar and WAR
files?
• JAR files are used for packaging and distributing
standalone Java applications or libraries,
• WAR files are used for packaging and distributing web
applications.
• Web-based applications need an internet connection,
servers, and any additional resources to run but
• Standalone applications do not require any additional
resources such as an internet connection, server, etc.
• Ex: Desktop software, Mobile apps, Gaming Applications, Industrial control
systems Medical Devices, etc.
Domain Specific Language (DSL)
• Domain Specific Language (DSL) is a specialized
programming language that's used for a single
purpose.
• Example - DSLs include: SQL (used for database
queries and data manipulation)
• Ex: CSS, regular expressions, make, ant, SQL, many
bits of Rails, expectations in JMock, graphviz's dot
language, strut's configuration file....
What is the basic introduction
of Maven in Spring Boot?
Maven
• Maven is a Build automation/Project management tool while Spring boot
provides RAD (Rapid Application Development) feature for applications using
spring framework.
• You can build spring boot applications using Maven, Gradle, SBT (If using
scala) and a lot of other build automation tools.
• The Spring Boot Maven Plugin provides Spring Boot support in Apache
Maven.
• It allows you to package executable jar or war archives, run Spring Boot
applications, generate build information and start your Spring Boot
application prior to running integration tests.
• Maven might be best for small projects,
• while Gradle is best for bigger projects.
Why Maven?
• do not want to keep all of your libraries in your project!
What is Gradle?
• Gradle is a build automation tool that is commonly used to build
software.
• A build automation tool is used to automate the creation of
applications, that includes everything from compiling to packaging
the code, making the process more consistent.
Basis Gradle Maven
Based on
Gradle is based on developing domain-specific language
projects.
Maven is based on developing pure Java
language-based software.
Configuration
It uses a Groovy-based Domain-specific language(DSL) for
creating project structure.
It uses Extensible Markup Language(XML) for
creating project structure.
Focuses on Developing applications by adding new features to them. Developing applications in a given time limit.
Performance
It performs better than maven as it optimized for tracking only
current running task.
It does not create local temporary files during
software creation, and is hence – slower.
Java Compilation It avoids compilation. It is necessary to compile.
Usability
It is a new tool, which requires users to spend a lot of time to
get used to it.
This tool is a known tool for many users and is
easily available.
Customization This tool is highly customizable as it supports a variety of IDE’s.
This tool serves a limited amount of developers
and is not that customizable.
Languages supported It supports software development in Java, C, C++, and Groovy.
It supports software development in Java, Scala,
C#, and Ruby.
Project Configuration
For declaring the project configuration, it does not use the
XML files.
For declaring the project configuration, it uses
the XML files.
Based on Graph of task dependencies that do the work. On the phases of the fixed and linear model.
Goal
To add functionality in the project is the main goal of the
Gradle.
To finish the project in the given timeline is the
main goal of the Maven.
What is a POM xml?
• A Project Object Model or POM is the fundamental
unit of work in Maven.
• It is an XML file that contains information about the
project and configuration details used by Maven to
build the project.
What is the difference between POM and
POM xml?
• POM stands for Project Object Model, and it is the core of a project's
configuration in Maven.
• It is a single configuration XML file called pom.
• xml that contains the majority of the information required to build a
project.
Is POM xml required?
• xml is required for building project using Maven.
• You might import jars manually in eclipse but for building the project
in some other build system which supports Maven, you would need
pom
Advantages of Spring Framework
• It is lightweight in nature due to its POJO implementation which
doesn’t force to inherit any class or implement any interfaces.
• Spring Framework supports other frameworks and its integration
makes Spring easier to develop.
• The Spring application is loosely couple due to Dependency Injection.
• The Spring Framework is easier to test and it doesn’t require any
server to run the application.
• It provides a powerful abstraction to JavaEE Specifications like JDBC,
JTA etc.
• Spring can remove the creation of the singleton and factory classes.
• Spring framework takes the best practices in all applications and
formalizes as design patterns.
Disadvantages of Spring Framework
• Complexity
• Parallel Mechanism: It provides multiple options to developers. These
options create confusion to developers that which feature to use and
which to not and wrong decisions may lead to significant delays.
• No Specific Guidelines: It does not care about XSS or cross-site
scripting.
• High Learning Curve: If you have not development experience in the
field, it would be quite difficult to learn It is difficult due to new
programming methods.
• Lots of XML: Developing a Spring application requires lots of XML.
Annotations in Java
• Annotations in Java provide additional information to the
compiler and JVM.
• An annotation is a tag representing metadata about classes,
interfaces, variables, methods, or fields.
• Annotations do not impact the execution of the code that they
annotate.
• Annotations start with @.
Its syntax is:
@AnnotationName
Spring Boot Annotations
• Spring Boot Annotations is a form of metadata that provides
data about a program.
• annotations are used to provide supplemental information
about a program.
• It is not a part of the application that we develop.
• It does not have a direct effect on the operation of the code
they annotate.
• It does not change the action of the compiled program.
@Controller / @RestController
• @Controller is a class-level annotation.
• It is a specialization of @Component.
• It marks a class as a web request handler.
• It is often used to serve web pages.
• By default, it returns a string that indicates which route to
redirect.
• It is mostly used with @RequestMapping annotation.
@GetMapping(“/hello”)
• The @GetMapping(“/hello”) tells Spring to use our hello() method to
answer requests that get sent to the http://localhost:8080/hello
address.
• @GetMapping: It maps the HTTP GET requests on the specific
handler method.
• It is used to create a web service endpoint that fetches It is used
instead of using:
@RequestMapping(method = RequestMethod.GET)
@ResponseBody
• The @ResponseBody annotation tells a controller
that the object returned is automatically serialized
into JSON and passed back into the HttpResponse
object.
References
• https://www.geeksforgeeks.org/introduction-to-spring-framework/
• https://docs.spring.io/spring-framework/reference/overview.html

More Related Content

Similar to Introduction to Spring & Spring BootFramework

Introduction to Spring
Introduction to SpringIntroduction to Spring
Introduction to SpringSujit Kumar
 
Introduction Java Web Framework and Web Server.
Introduction Java Web Framework and Web Server.Introduction Java Web Framework and Web Server.
Introduction Java Web Framework and Web Server.suranisaunak
 
Java Training in Chennai
Java Training in Chennai Java Training in Chennai
Java Training in Chennai raj esaki
 
5 Treding Java Frameworks Offshore Developers Should About
5 Treding Java Frameworks Offshore Developers Should About5 Treding Java Frameworks Offshore Developers Should About
5 Treding Java Frameworks Offshore Developers Should AboutBJIT Ltd
 
Spring Framework Tutorial | VirtualNuggets
Spring Framework Tutorial | VirtualNuggetsSpring Framework Tutorial | VirtualNuggets
Spring Framework Tutorial | VirtualNuggetsVirtual Nuggets
 
Java fundamentals
Java fundamentalsJava fundamentals
Java fundamentalsOm Ganesh
 
Fundamentals of JAVA
Fundamentals of JAVAFundamentals of JAVA
Fundamentals of JAVAKUNAL GADHIA
 
Java v/s .NET - Which is Better?
Java v/s .NET - Which is Better?Java v/s .NET - Which is Better?
Java v/s .NET - Which is Better?NIIT India
 
Spring presentecion isil
Spring presentecion isilSpring presentecion isil
Spring presentecion isilWilly Aguirre
 
Spring presentecion isil
Spring presentecion isilSpring presentecion isil
Spring presentecion isilWilly Aguirre
 

Similar to Introduction to Spring & Spring BootFramework (20)

java full 1 (Recovered).docx
java full 1 (Recovered).docxjava full 1 (Recovered).docx
java full 1 (Recovered).docx
 
Introduction to Spring
Introduction to SpringIntroduction to Spring
Introduction to Spring
 
Spring ppt
Spring pptSpring ppt
Spring ppt
 
Introduction Java Web Framework and Web Server.
Introduction Java Web Framework and Web Server.Introduction Java Web Framework and Web Server.
Introduction Java Web Framework and Web Server.
 
Java Training in Chennai
Java Training in Chennai Java Training in Chennai
Java Training in Chennai
 
5 Treding Java Frameworks Offshore Developers Should About
5 Treding Java Frameworks Offshore Developers Should About5 Treding Java Frameworks Offshore Developers Should About
5 Treding Java Frameworks Offshore Developers Should About
 
Spring Framework Rohit
Spring Framework RohitSpring Framework Rohit
Spring Framework Rohit
 
Spring Framework Tutorial | VirtualNuggets
Spring Framework Tutorial | VirtualNuggetsSpring Framework Tutorial | VirtualNuggets
Spring Framework Tutorial | VirtualNuggets
 
spring
springspring
spring
 
Java fundamentals
Java fundamentalsJava fundamentals
Java fundamentals
 
Top Java Frameworks.pdf
Top Java Frameworks.pdfTop Java Frameworks.pdf
Top Java Frameworks.pdf
 
Fundamentals of JAVA
Fundamentals of JAVAFundamentals of JAVA
Fundamentals of JAVA
 
unit1.pptx
unit1.pptxunit1.pptx
unit1.pptx
 
What is maven
What is mavenWhat is maven
What is maven
 
Spring
SpringSpring
Spring
 
Java v/s .NET - Which is Better?
Java v/s .NET - Which is Better?Java v/s .NET - Which is Better?
Java v/s .NET - Which is Better?
 
Spring presentecion isil
Spring presentecion isilSpring presentecion isil
Spring presentecion isil
 
Spring presentecion isil
Spring presentecion isilSpring presentecion isil
Spring presentecion isil
 
Devjyotippt
DevjyotipptDevjyotippt
Devjyotippt
 
Java Introduction
Java IntroductionJava Introduction
Java Introduction
 

More from Kongu Engineering College, Perundurai, Erode

More from Kongu Engineering College, Perundurai, Erode (20)

A REST API (also called a RESTful API or RESTful web API) is an application p...
A REST API (also called a RESTful API or RESTful web API) is an application p...A REST API (also called a RESTful API or RESTful web API) is an application p...
A REST API (also called a RESTful API or RESTful web API) is an application p...
 
SOA and Monolith Architecture - Micro Services.pptx
SOA and Monolith Architecture - Micro Services.pptxSOA and Monolith Architecture - Micro Services.pptx
SOA and Monolith Architecture - Micro Services.pptx
 
Application Layer.pptx
Application Layer.pptxApplication Layer.pptx
Application Layer.pptx
 
Connect to NoSQL Database using Node JS.pptx
Connect to NoSQL Database using Node JS.pptxConnect to NoSQL Database using Node JS.pptx
Connect to NoSQL Database using Node JS.pptx
 
Node_basics.pptx
Node_basics.pptxNode_basics.pptx
Node_basics.pptx
 
Navigation Bar.pptx
Navigation Bar.pptxNavigation Bar.pptx
Navigation Bar.pptx
 
Bootstarp installation.pptx
Bootstarp installation.pptxBootstarp installation.pptx
Bootstarp installation.pptx
 
nested_Object as Parameter & Recursion_Later_commamd.pptx
nested_Object as Parameter  & Recursion_Later_commamd.pptxnested_Object as Parameter  & Recursion_Later_commamd.pptx
nested_Object as Parameter & Recursion_Later_commamd.pptx
 
Chapter 3.pdf
Chapter 3.pdfChapter 3.pdf
Chapter 3.pdf
 
Introduction to Social Media and Social Networks.pdf
Introduction to Social Media and Social Networks.pdfIntroduction to Social Media and Social Networks.pdf
Introduction to Social Media and Social Networks.pdf
 
Dropdown Menu or Combo List.pdf
Dropdown Menu or Combo List.pdfDropdown Menu or Combo List.pdf
Dropdown Menu or Combo List.pdf
 
div tag.pdf
div tag.pdfdiv tag.pdf
div tag.pdf
 
Dimensions of elements.pdf
Dimensions of elements.pdfDimensions of elements.pdf
Dimensions of elements.pdf
 
CSS Positioning Elements.pdf
CSS Positioning Elements.pdfCSS Positioning Elements.pdf
CSS Positioning Elements.pdf
 
Random number generation_upload.pdf
Random number generation_upload.pdfRandom number generation_upload.pdf
Random number generation_upload.pdf
 
JavaScript_introduction_upload.pdf
JavaScript_introduction_upload.pdfJavaScript_introduction_upload.pdf
JavaScript_introduction_upload.pdf
 
Computer Networks: Quality of service
Computer Networks: Quality of serviceComputer Networks: Quality of service
Computer Networks: Quality of service
 
Transport layer protocols : Simple Protocol , Stop and Wait Protocol , Go-Bac...
Transport layer protocols : Simple Protocol , Stop and Wait Protocol , Go-Bac...Transport layer protocols : Simple Protocol , Stop and Wait Protocol , Go-Bac...
Transport layer protocols : Simple Protocol , Stop and Wait Protocol , Go-Bac...
 
Transport layer services
Transport layer servicesTransport layer services
Transport layer services
 
Transport layer protocols : TCP and UDP
Transport layer protocols  : TCP and UDPTransport layer protocols  : TCP and UDP
Transport layer protocols : TCP and UDP
 

Recently uploaded

08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your Budget
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your BudgetHyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your Budget
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your BudgetEnjoy Anytime
 
How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?XfilesPro
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...HostedbyConfluent
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhisoniya singh
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 

Recently uploaded (20)

08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food Manufacturing
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your Budget
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your BudgetHyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your Budget
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your Budget
 
How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 

Introduction to Spring & Spring BootFramework

  • 2. Who invented Spring Framework • Rod Johnson • Spring (previously known as SpringSource) was a software company founded by Rod Johnson, who also created the Spring Framework, an open-source application framework for enterprise Java applications.
  • 3. What is the basic concept of Spring? • Spring is considered to be a secure, low-cost and flexible framework that improves coding efficiency and reduces overall application development time through efficient use of system resources. • Spring removes tedious configuration work so that developers can focus on writing business logic
  • 4. What is Spring used for? • It helps application developers to perform the following functions:4 • Create a Java method that runs in a database transaction with no help from transaction APIs. • Create a local Java method that defines a remote procedure with no help from remote APIs.
  • 5. How to use Spring Framework? • Create the Bean. java class. • Create a XML/ configuration file. • Create the main class. • Load the required jar files. • Run the application.
  • 6. Why to Learn Spring? • Spring is the application development framework for enterprise Java. • to create high performing, easily testable, and reusable code. • Spring framework is an open source Java platform. It was initially written by Rod Johnson and was first released under the Apache 2.0 license in June 2003. • Spring is lightweight when it comes to size and transparency. The basic version of Spring framework is around 2MB. • Spring framework targets to make J2EE development easier to use and promotes good programming practices by enabling a POJO-based programming model. • Plain old Java object (POJO) is a class definition
  • 7. What is POJO and why it is used? •POJO stands for Plain Old Java Object. •It is used to describe a Java class that follows simple conventions and does not depend on any specific frameworks or libraries. •A POJO typically contains private fields with corresponding getter and setter methods, and it may also include additional methods for behaviour.
  • 8. Differences Between POJO and Java beans • POJO can have other than private fields whereas Java beans can only have private fields. • POJO may or may not have a constructor whereas Java beans should have a no-argument constructor.
  • 9. public class test implements Serializable { private String a; public test(){} public String getA() {return a;} public void setA(String a) {this.a=a;} } Example java Bean & POJO
  • 10. Applications / benefits of Spring • POJO Based - Spring enables developers to develop enterprise-class applications using POJOs. • The benefit of using only POJOs is that you do not need an EJB container product such as an application server but you have the option of using only a robust servlet container such as Tomcat or some commercial product. • Modular - Spring is organized in a modular fashion. Even though the number of packages and classes are substantial.
  • 11. Applications / benefits of Spring • Integration with existing frameworks • Testablity - Testing an application written with Spring is simple because. environment-dependent code is moved into this framework • By using JavaBeanstyle POJOs, it becomes easier to use dependency injection for injecting test data. • Web MVC - which provides a great alternative to web frameworks such as Struts or other over-engineered or less popular web frameworks.
  • 12. Applications / benefits of Spring • Central Exception Handling - Spring provides a convenient API to translate technology-specific exceptions (thrown by JDBC, Hibernate, or JDO, for example) into consistent, unchecked exceptions. • Lightweight - Lightweight IoC containers tend to be lightweight, especially when compared to EJB containers, for example. This is beneficial for developing and deploying applications on computers with limited memory and CPU resources. • Transaction management - Spring provides a consistent transaction management interface that can scale down to a local transaction (using a single database, for example) and scale up to global transactions (using JTA, for example).
  • 13. Spring's Inversion of Control (IoC) container • It is responsible for instantiating, configuring and assembling objects known as beans, as well as managing their life cycles
  • 14. Dependency Injection (DI) • Dependency Injection (DI) is a design pattern used to implement IoC. • It allows the creation of dependent objects outside of a class and provides those objects to a class through different ways. • It removes the dependency of the programs. In such case we provide the information from the external source such as XML file. • It makes code loosely coupled and easier for testing. • Using DI, we move the creation and binding of the dependent objects outside of the class that depends on them.
  • 15. The Dependency Injection pattern involves 3 types of classes. • Client Class: The client class (dependent class) is a class which depends on the service class • Service Class: The service class (dependency) is a class that provides service to the client class. • Injector Class: The injector class injects the service class object into the client class. • The following figure illustrates the relationship between these classes:
  • 16. Types of Dependency Injection • the injector class injects the service (dependency) to the client (dependent). • The injector class injects dependencies broadly in three ways: • through a constructor, • through a property, or • through a method.
  • 17. class Employee{ Address address; Employee(Address address){ this.address=address; } public void setAddress(Address address){ this.address=address; } }
  • 18.
  • 19.
  • 20.
  • 23. What is difference between jar and WAR files? • JAR files are used for packaging and distributing standalone Java applications or libraries, • WAR files are used for packaging and distributing web applications. • Web-based applications need an internet connection, servers, and any additional resources to run but • Standalone applications do not require any additional resources such as an internet connection, server, etc. • Ex: Desktop software, Mobile apps, Gaming Applications, Industrial control systems Medical Devices, etc.
  • 24. Domain Specific Language (DSL) • Domain Specific Language (DSL) is a specialized programming language that's used for a single purpose. • Example - DSLs include: SQL (used for database queries and data manipulation) • Ex: CSS, regular expressions, make, ant, SQL, many bits of Rails, expectations in JMock, graphviz's dot language, strut's configuration file....
  • 25. What is the basic introduction of Maven in Spring Boot?
  • 26. Maven • Maven is a Build automation/Project management tool while Spring boot provides RAD (Rapid Application Development) feature for applications using spring framework. • You can build spring boot applications using Maven, Gradle, SBT (If using scala) and a lot of other build automation tools. • The Spring Boot Maven Plugin provides Spring Boot support in Apache Maven. • It allows you to package executable jar or war archives, run Spring Boot applications, generate build information and start your Spring Boot application prior to running integration tests. • Maven might be best for small projects, • while Gradle is best for bigger projects.
  • 27. Why Maven? • do not want to keep all of your libraries in your project!
  • 28. What is Gradle? • Gradle is a build automation tool that is commonly used to build software. • A build automation tool is used to automate the creation of applications, that includes everything from compiling to packaging the code, making the process more consistent.
  • 29. Basis Gradle Maven Based on Gradle is based on developing domain-specific language projects. Maven is based on developing pure Java language-based software. Configuration It uses a Groovy-based Domain-specific language(DSL) for creating project structure. It uses Extensible Markup Language(XML) for creating project structure. Focuses on Developing applications by adding new features to them. Developing applications in a given time limit. Performance It performs better than maven as it optimized for tracking only current running task. It does not create local temporary files during software creation, and is hence – slower. Java Compilation It avoids compilation. It is necessary to compile. Usability It is a new tool, which requires users to spend a lot of time to get used to it. This tool is a known tool for many users and is easily available. Customization This tool is highly customizable as it supports a variety of IDE’s. This tool serves a limited amount of developers and is not that customizable. Languages supported It supports software development in Java, C, C++, and Groovy. It supports software development in Java, Scala, C#, and Ruby. Project Configuration For declaring the project configuration, it does not use the XML files. For declaring the project configuration, it uses the XML files. Based on Graph of task dependencies that do the work. On the phases of the fixed and linear model. Goal To add functionality in the project is the main goal of the Gradle. To finish the project in the given timeline is the main goal of the Maven.
  • 30. What is a POM xml? • A Project Object Model or POM is the fundamental unit of work in Maven. • It is an XML file that contains information about the project and configuration details used by Maven to build the project.
  • 31.
  • 32. What is the difference between POM and POM xml? • POM stands for Project Object Model, and it is the core of a project's configuration in Maven. • It is a single configuration XML file called pom. • xml that contains the majority of the information required to build a project.
  • 33. Is POM xml required? • xml is required for building project using Maven. • You might import jars manually in eclipse but for building the project in some other build system which supports Maven, you would need pom
  • 34. Advantages of Spring Framework • It is lightweight in nature due to its POJO implementation which doesn’t force to inherit any class or implement any interfaces. • Spring Framework supports other frameworks and its integration makes Spring easier to develop. • The Spring application is loosely couple due to Dependency Injection. • The Spring Framework is easier to test and it doesn’t require any server to run the application. • It provides a powerful abstraction to JavaEE Specifications like JDBC, JTA etc. • Spring can remove the creation of the singleton and factory classes. • Spring framework takes the best practices in all applications and formalizes as design patterns.
  • 35. Disadvantages of Spring Framework • Complexity • Parallel Mechanism: It provides multiple options to developers. These options create confusion to developers that which feature to use and which to not and wrong decisions may lead to significant delays. • No Specific Guidelines: It does not care about XSS or cross-site scripting. • High Learning Curve: If you have not development experience in the field, it would be quite difficult to learn It is difficult due to new programming methods. • Lots of XML: Developing a Spring application requires lots of XML.
  • 36. Annotations in Java • Annotations in Java provide additional information to the compiler and JVM. • An annotation is a tag representing metadata about classes, interfaces, variables, methods, or fields. • Annotations do not impact the execution of the code that they annotate. • Annotations start with @. Its syntax is: @AnnotationName
  • 37. Spring Boot Annotations • Spring Boot Annotations is a form of metadata that provides data about a program. • annotations are used to provide supplemental information about a program. • It is not a part of the application that we develop. • It does not have a direct effect on the operation of the code they annotate. • It does not change the action of the compiled program.
  • 38. @Controller / @RestController • @Controller is a class-level annotation. • It is a specialization of @Component. • It marks a class as a web request handler. • It is often used to serve web pages. • By default, it returns a string that indicates which route to redirect. • It is mostly used with @RequestMapping annotation.
  • 39. @GetMapping(“/hello”) • The @GetMapping(“/hello”) tells Spring to use our hello() method to answer requests that get sent to the http://localhost:8080/hello address. • @GetMapping: It maps the HTTP GET requests on the specific handler method. • It is used to create a web service endpoint that fetches It is used instead of using: @RequestMapping(method = RequestMethod.GET)
  • 40. @ResponseBody • The @ResponseBody annotation tells a controller that the object returned is automatically serialized into JSON and passed back into the HttpResponse object.