Mastering Spring and Spring Boot: A Comprehensive Guide, Slides of Computer science

This document overviews the Spring Framework and Spring Boot, emphasizing their importance in Java development. It covers key concepts like dependency injection, IoC, autowiring, and auto-configuration, explaining how these frameworks simplify web application, REST API, and microservice development. It explores Spring fundamentals, including loose coupling, Spring beans, and annotations, offering insights into building robust, maintainable applications. Designed for beginners, it provides a practical approach with examples and quizzes to reinforce learning. It emphasizes Spring's benefits for managing object lifecycles and dependencies, letting developers focus on business logic. It also addresses best practices for effective Spring development.

Typology: Slides

2023/2024

Uploaded on 08/02/2025

your-partner-it-engineer
your-partner-it-engineer šŸ‡¬šŸ‡§

1 document

1 / 231

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Master Spring & Spring Boot
with Hibernate & React
1
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f
pf20
pf21
pf22
pf23
pf24
pf25
pf26
pf27
pf28
pf29
pf2a
pf2b
pf2c
pf2d
pf2e
pf2f
pf30
pf31
pf32
pf33
pf34
pf35
pf36
pf37
pf38
pf39
pf3a
pf3b
pf3c
pf3d
pf3e
pf3f
pf40
pf41
pf42
pf43
pf44
pf45
pf46
pf47
pf48
pf49
pf4a
pf4b
pf4c
pf4d
pf4e
pf4f
pf50
pf51
pf52
pf53
pf54
pf55
pf56
pf57
pf58
pf59
pf5a
pf5b
pf5c
pf5d
pf5e
pf5f
pf60
pf61
pf62
pf63
pf64

Partial preview of the text

Download Mastering Spring and Spring Boot: A Comprehensive Guide and more Slides Computer science in PDF only on Docsity!

Master Spring & Spring Boot

with Hibernate & React

Top frameworks in the Java world today

Spring Framework

Spring Boot

Beginners find the first steps very difficult :

Lot of terminology : Dependency Injection, IOC, Auto

wiring, Auto configuration, Starter Projects ..

Variety of applications : Web app, REST API, Full Stack

Variety of other framework, tool and platform

integrations : Maven, Gradle, Spring Data, JPA, Hibernate,

Docker and Cloud

Getting Started

Learning Spring & Spring Boot

can be tricky : Lots of new terminology, tools and frameworks

As time passes, we forget things

How do you improve your

chances of remembering

things? Active learning - think & make notes Review the presentation once in a while

How do you put your best foot forward?

Videos with:

Presentations &

Demos where we build projects

Quizzes :

To Reinforce Concepts

(Recommended) Take your

time. Do not hesitate to

replay videos!

(Recommended) Have Fun!

Our Approach

Spring Framework

You can build a variety of applications using

Java, Spring and Spring Boot: Web REST API Full Stack Microservices

Irrespective of the app you are building: Spring framework provides all the core features Understanding Spring helps you learn Spring Boot easily Helps in debugging problems quickly

In this module, we focus extensively on Spring

Framework

Getting Started with Spring Framework - Why?

Design Game Runner to run games (Mario, SuperContra, Pacman etc) in an iterative approach : Iteration 1 : Tightly Coupled Java Code GameRunner class Game classes: Mario, SuperContra, Pacman etc Iteration 2 : Loose Coupling - Interfaces GameRunner class GamingConsole interface Game classes: Mario, SuperContra, Pacman etc Iteration 3 : Loose Coupling - Spring Level 1 Spring Beans Spring framework will manage objects and wiring Iteration 4 : Loose Coupling - Spring Level 2 Spring Annotations Spring framework will create, manage & auto-wire objects ...

Getting Started with Spring Framework - Approach

Very Few Spring Framework users understand fundamentals: Spring Container vs Spring Context vs IOC Container vs Application Context Java Bean vs Spring Bean Auto Wiring vs Dependency Injection How can you build loosely coupled applications? Making good use of Java Interfaces along with Spring

We spent multiple weeks designing this section to help you understand these fundamentals

This is the most important section of the course: Focus really well to understand the fundamentals Good luck!

Do you want to do well at interviews?

Coupling : How much work is involved in changing something? Coupling is important everywhere: An engine is tightly coupled to a Car A wheel is loosely coupled to a Car You can take a laptop anywhere you go A computer, on the other hand, is a little bit more difficult to move Coupling is even more important in building great soware Only thing constant in technology is change Business requirements change Frameworks change Code changes We want Loose Coupling as much as possible We want to make functional changes with as less code changes as possible

Let's explore how Java Interfaces and Spring Framework help with Loose Coupling!

Why is Coupling Important?

Question 1 : Spring Container vs Spring Context vs IOC Container vs Application Context

Question 2 : Java Bean vs Spring Bean

Question 3 : How can I list all beans managed by Spring Framework?

Question 4 : What if multiple matching beans are available?

Question 5 : Spring is managing objects and performing auto-wiring. BUT aren't we writing the code to create objects? How do we get Spring to create objects for us?

Question 6 : Is Spring really making things easy?

Spring Questions You Might Be Thinking About

Java Bean : Classes adhering to 3 constraints: 1: Have public default (no argument) constructors 2: Allow access to their properties using getter and setter methods 3: Implement java.io.Serializable

POJO : Plain Old Java Object No constraints Any Java Object is a POJO!

Spring Bean : Any Java object that is managed by Spring Spring uses IOC Container (Bean Factory or Application Context) to manage these objects

Exploring Java Bean vs POJO vs Spring Bean

Constructor-based : Dependencies are set

by creating the Bean using its Constructor

Setter-based : Dependencies are set by

calling setter methods on your beans

Field : No setter or constructor.

Dependency is injected using reflection.

Question: Which one should you use? Spring team recommends Constructor-based injection as dependencies are automatically set when an object is created!

Exploring Spring - Dependency Injection Types

@Primary vs @Qualifier - Which one to use?

@Primary - A bean should be given preference when multiple candidates are qualified @Qualifier - A specific bean should be auto-wired (name of the bean can be used as qualifier) ALWAYS think from the perspective of the class using the SortingAlgorithm: 1: Just @Autowired : Give me (preferred) SortingAlgorithm 2: @Autowired + @Qualifier : I only want to use specific SortingAlgorithm - RadixSort (REMEMBER) @Qualifier has higher priority then @Primary

@Componentclass QuickSort @Primary implement SortingAlgorithm {} @Componentclass BubbleSort implement SortingAlgorithm {} @Componentclass RadixSort @Qualifier("RadixSortQualifier") implement SortingAlgorithm {} @Componentclass ComplexAlgorithm @Autowiredprivate SortingAlgorithm algorithm; @Componentclass AnotherComplexAlgorithm @Autowiredprivate SortingAlgorithm @Qualifier("RadixSortQualifier") iWantToUseRadixSortOnly;

@Component (..): An instance of class will be managed by Spring framework

Dependency : GameRunner needs GamingConsole impl! GamingConsole Impl (Ex: MarioGame) is a dependency of GameRunner

Component Scan : How does Spring Framework find component classes? It scans packages! (@ComponentScan("com.in28minutes"))

Dependency Injection : Identify beans, their dependencies and wire them together (provides IOC - Inversion of Control) Spring Beans : An object managed by Spring Framework IoC container : Manages the lifecycle of beans and dependencies Types : ApplicationContext (complex), BeanFactory (simpler features - rarely used) Autowiring : Process of wiring in dependencies for a Spring Bean

Spring Framework - Important Terminology