What is framework?
- A framework is like ready made toolset or structure ,it helps you build application easily , without starting from scratch.
what is spring?
- Spring Framework is a java-based opens-source framework , it is used to build enterprise level, scalable, maintainable application.
- spring provide infrastructure support for building java apps by managing dependencies injection , configuration, connecting to databases, handle web request and so on.
- Need External Server (Tomcat)
Developed by Rod Johnson in 2002.
Spring Follows principle Dependency injection(like without new keyword create the object, spring container(object memory location) ,to use @Autowired) and Aspect-Oriented programming(AOP),MVC(Model-view-Controller)
AOP: is a programming concept to used to separate common function like logging ,security,transactions from main logic of you application. simple, write common code(logging, security, transactions) and automatically apply you app or application , without rewrite it everywhere
Deployment : Build WAR, needs external server
Configuration: Manual xml based configuration it is older style ,you define everything in xmf flie.spring 2.5 version you can use also annotation so spring support both XML and annotation , but need more setup. in Spring boot no need xml Configuration you just add dependencies in pom.xml,it will auto configure everything ,start the application , scan your classes with annotation like @Restcontroller ,@Service ..etc.
spring Example:-
applicationContext.xml or beans.xml
<bean id="studentService" class="com.example.StudentService"/>
<context:component-scan base-package="com.example"/>
spring boot dependency injection Example:-
pom.xml
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
before you added dependency in pom.xml ,now Spring boot code now you can use annotations @ annotation:-
@RestController
public class MyController {
@GetMapping("/hello")
public String hello() {
return "Hello!";
}
}
<bean id="myBean" class="com.example.MyBean"/>
Annotation-based:-
you use java annotation instead of xml
Common annotations:
@Component, @Service, @Repository, @Controller ...etc
What is annotation:-
Annotation is meta data that mean data about data, data about data mean provide info about to the spring framework,These annotation used to configure,customize, reduce xmL configuration and boilerplate code ( repeated code not a main logic), annotation make developer develop application or app simplify development and maintain and efficient ,time reduce..etc.
How to avoid boilerplate code:-
- manual creating beans:-
<bean id="studentService" class="com.example.StudentService"/>
how to avoid : use annotation like @service and @ auto wired ,automatically crate and inject bean(object).
- Auto Configuration
Automatically set up Db ,server..etc.it make consuming more time and managnet difficulty so, how to avoid:
spring boot add automatically configure you application based on dependencies what you added in the pom.xml and some more setting in application.properties or application.yml. like you want project server tomcat , you can inject dependencies your pom.xml(maven) spring automatically download internet you dependencies.
In a project you can see src/main/properties under you can see application.properties it used to .
Configure application setting like port number changing ,Db config..etc.
3.Getter/setters
How to avoid Getter/setters : Lombok , remove getter/setters , use @data and @Getter ,.etc.
application.yml:-
YAML format for settings
What is Dependencies and Dependencies injection and types:-
Dependency:-
Dependency is a class/object that another need to work.
Example:-
class Engine
{
public void start()
{
sytem.out.println("engine started Let to drive");
}
}
class Car {
Engine engine = new Engine(); // tightly coup
engine.start();
// Engine is a dependency
// Engine class change constructor , you must chage every place that uses it.
}
// car depends on Engine , so Engine dependency of car
What is Dependency Injection (DI)?
- Dependency Injection is a is a design pattern, do not create the object yourself with new key word(tightly couple) ,spring or spring boot create and inject required object with help of @Component(you can tell spring ,pleas create objects of this class,spring will manage and create bean(object) ),spring container(memory location hold all object (@Componet in top of class use )),@Autowired (connector like tell spring inject(connect) this object here) ,spring container is one of the part of heap memory.
Why Heap?
Because:
- All Java objects are stored in the heap memory
- Spring beans are also Java objects.
Example:
Normal java or spring boot or spring you can create object with new keyword it is manual ,it make depend upon other like called tightly coupled when depender class anything change(parent)like constructor like parameter constructor/overload ,you can change all so depending class(child class) constructor or object values.
class Engine
{
public void start()
{
sytem.out.println("engine started Let to drive");
}
}
class Car {
//Engine engine = new Engine(); // Manual
@Autowired
Engine engine; // Spring injects it
engine.start();
// Engine is a dependency
// @Autowired if you want you first inject dependency to pom.xml , maven will manage
}
Why to use DI:-
- Reduce manual object creation
- Loose Coupling - easy to change
Types of Dependency Injection in Spring?
1. Constructor Injection
Spring passes dependency to the constructor
@Component
class Car {
private final Engine engine;
public Car(Engine engine) {
this.engine = engine;
}
}
2️2.Setter Injection:-
Spring sets dependency using setter method
@Component
class Car {
private Engine engine;
@Autowired
public void setEngine(Engine engine) {
this.engine = engine;
}
}
3. Field Injection
Spring injects directly into the field
@Component
class Car {
@Autowired
private Engine engine;
}
Aop example:
without AOP( repeating code every where)
public class BankService {
public void withdraw() {
System.out.println("Checking permission...");
System.out.println("Logging: withdraw started");
System.out.println("Withdrawing money...");
System.out.println("Logging: withdraw completed");
}
public void deposit() {
System.out.println("Checking permission...");
System.out.println("Logging: deposit started");
System.out.println("Depositing money...");
System.out.println("Logging: deposit completed");
}
public void checkBalance() {
System.out.println("Checking permission...");
System.out.println("Logging: check balance started");
System.out.println("Showing balance...");
System.out.println("Logging: check balance completed");
}
}
// main logic with extra logic , hard to mange,messy..etc
With AOP (clean and separate)
public class BankService {
public void withdraw() {
System.out.println("Withdrawing money...");
}
public void deposit() {
System.out.println("Depositing money...");
}
public void checkBalance() {
System.out.println("Showing balance...");
}
}
Step 2: Write AOP for Logging and Permission
@Aspect
@Component
public class LoggingAspect {
// Log before any method in BankService
@Before("execution(* com.example.BankService.*(..))")
public void logBefore(JoinPoint jp) {
System.out.println("Logging: " + jp.getSignature().getName() + " started");
}
@After("execution(* com.example.BankService.*(..))")
public void logAfter(JoinPoint jp) {
System.out.println("Logging: " + jp.getSignature().getName() + " completed");
}
@Before("execution(* com.example.BankService.*(..))")
public void checkPermission() {
System.out.println("Checking permission...");
}
}
// But you didn’t write this logging or permission code inside the withdraw() method — Spring AOP handled it for you.
Is Spring only for Java?
yes, Spring is only for Java and JVM-based languages (like Kotlin, Groovy).
It is not for Python, C++, etc.
Why use Spring?
- To build robust(Strong,stable,handle errors well,)loosely coupled(classes are independent not tightly coupled , Java applications.
Can integrate with JPA/Hibernate, JDBC, Security, etc.
JPA (Java Persistence API)
- JPA is just a specification (like a set of rules).
- It defines how Java objects should be saved into a database (ORM – Object Relational Mapping).
- JPA doesn’t do anything by itself – it needs a real tool to work.
Hibernate
- Hibernate is a real tool (framework) that follows JPA rules.
- So, Hibernate is a popular implementation of JPA.
- It does the actual work of connecting your Java classes to the database.
Example:-
Think of:-
Hibernate = Worker who follows the rulebook
- sql maually, JDBC, Security, etc.
What is JDBC?
-
JDBC = Java Database Connectivity (manual SQL writing and executing)
When to use:
-
When you want manual control over SQL.
How Spring Integrates:
Spring provides Jdbc Template to reduce boilerplate code.
Spring Security:-
What is it?
- A module in Spring for:
- Login/Logout
- User Roles (admin, user, etc.)
- Password Encryption
- Authorization (what a user can access)
How Spring Integrates:
- Add spring-boot-starter-security
- Configure user roles, login form, URL access rules
Example
Tightly coupling:-
class Car {
Engine engine = new Engine(); // direct object
}
loose coupling
class Car {
@Autowired
Engine engine; // Spring will inject it
// you can change the engine ,test the calss , or reuse iit
}
- IT save time ,Make code clean and reusable
- It give tools for web apps ,security ,database,JPA/Hibernate, JDBC.
- Supports DI, AOP, and MVC, simplifying development.
what is Spring Boot?
Spring boot is a simplified version of the Spring Framework. It helps to create spring applications quickly and with less configuration.
Spring Boot = spring + Ready made setup(like auto configuration ..etc) +Less code + fast to development like you can create java web apps to fast.
Developed by Pivotal (now VMware) in 2014.
Deployment : Build JAR with embedded Tomcat/Jetty(server)
Use Case:-
spring : Full control, more configuration setup ,suitable for custom projects
Spring Boot: Fast startup the projects,Rest APIS, Micro-service, ..etc.
Example:
- without spring: you write 100 lines for setup code.
- with spring : you write 20 lines.
- With spring Boot : you write 10 lines
why to use Spring Boot?
- Reduce boilerplate code( boilerplate code- repeated code , you write agin and again) ,to avoid writing unnecessary code.
- Easy to start project with pre-configured setups.it useful for beginners.
- To avoid complex XML configurations.
- Ideal for micro services architecture
*we will learn some concept or tool or other terminology used in the spring boot project *
What is Maven?
(A Java tool to manage dependencies and build project)
- Maven is a build and dependency management tool for Java projects.
- Configuration format : XML (pom.xml)
- Speed: Slower
- Used in Spring Boot, standard Java app
s
- Dependency Management: Downloads libraries (JAR files) only from Maven Central repository
- It helps:
- Download and manage external libraries (like Spring Boot..etc)
- Build your project (compile, test, package into .jar or .war)
- Run your project with the required libraries
What is Gradle?
- Gradle Build & Dependency Management Tool like maven.
- Configuration format : Groovy or Kotlin DSL (build.gradle)
- synax: Concise like script based
- speed: Faster
- Dependency Management: Can download from Maven Central, JCenter, or custom/private sources.
- used in : Andriod apps, spring Boot Apps ,large java projects.
What is jar ?
jar = Java ARchive
- Jar File is a packaged java application(all java files are combined into one file .jar so it easy to run ,share,or deploy ) used to run standalone programs.JAR file is a zip file that contains your Java program
standalone mean:
- work independently.
- no need to deploy on separate server tomcat manually.that mean just run the jar file directly using java no need to put in separate server like tomcat.
- Easy to run,test and move.
Example:
- you build you spring boot app like myapp.jar
- run using java -jar myapp.jar
3.spring start its own server on port of 8080 by default
4.you open browser ->http://localhost:8080
app is running this is called deployment for JAR
Jar file contains all compiled .class files, libraries, and metadata(info about how to run).
Runs directly using: java -jar app.jar
used in Spring Boot, microservices, and CLI apps.Running desktop or back end apps.Standalone Java applications
jar not need install server separately , include tomcat server run app directly
Tools -> Maven/Gradle to build .jar
what is WAR?
WAR = Web Application Archive
A WAR file is a packaged Java web application(means java web project with contain HtmL,CSS,Java code,etc) that zipped into one .war file to be run on a webserver) used to deploy on web servers like Tomcat in deploy. Deploy mean putting your application on a sever so users can access it.
WAR Contains: .class files + HTML, CSS, JS, JSP, WEB-INF folder, etc.
Example:-
1.you build you app -> myapp.war ( create you web app)
2.you copy to C:\tomcat\webapps\myapp.war (after placed your web app in the server tomcat)
3.Start tomcat
4.open browser and paste => http://localhost:8080/myapp (server run your app and it make available in the browser)
now deployed and running
Deploy -> Putting your app on a server to run
WAR file -> The package you give to the server
Tomcat -> The server that runs your web app.
used for Deploying java apps to web server(Apache Tomcat) .Web-based applications (Servlet, JSP, deployed to server)
Tools -> Maven/Gradle to build .war
What is pom.xml in Spring Boot ?
(XML file used by Maven to define project setup)
POM = Project Object Model
- pom.xml it is a XML file(your required dependency placed or add into pom.xml) used by maven tool ,that to tool manage the dependencies in you project. pom.xml tells maven what is project name(artifactId),package name (groupId),what version,What dependencies (JARs) to download,What plugins or settings to use.
What is XML in pom.xml?
XML = Extensible Markup Language
It is used to store structured data.
it use tags likevalue
XML is platform-independent and readable by humans and machines. that mean do not depend on any operating system ,can be used or support on every platform like Windows, linux,mac,android,server...etc
What is a Dependency in pom.xml?
- I want to use some external java library or tool like spring boot ,jpa,hibernate, please download and include my project. like simply say maven is a tool it mange dependencies in the project,that dependencies placed in pom.xml for example you add dependencies in pom.xml spring tell maven tool download dependencies form internet file like jar file , that jar file combination package and class available.
Example:-
pom.xml
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
// this dependency say i want to use spring boot for build web application, maven download required library the you add project @RestController, @GetMapping, etc.
What Happens When You Use Maven?
When you run:
mvn clean install
Maven will:
- Read pom.xml
- Download all dependencies (JAR files) from the internet (Maven Central)
- Compile the code
- Run tests
- Create a .jar or .war file to run your app
Where Are the JAR Files Stored?
Maven downloads all .jar files into:
C:\Users\YourName\.m2\repository (Windows)
or
~/.m2/repository (Linux/macOS)
- JAR in Maven Downloaded from the internet and stored in .m2
java is WORA feature write once anywhere ,platform independence , windows, linux.
500 .class to files to :Zip : in java caller jar
.yaml/.yml
YAML Ain’t Markup Language:Easy to read and write.
- Used in : Configuration files (application.yml)in Spring Boot, Docker (docker-compose.yml), Kubernetes (deployment.yml), Ansible, etc.
Feature : Human-readable data serialization language , indentation-based.
Structure: Based on indentation (like Python)
Supports: Key-value pairs, lists, nested structures.
No tags, no brackets
Real-time use: Configure properties like ports, DB, paths.
data serialization language mean:
IT means it help store data in structured ,readable format.
IT can represent data like string,number,list,object..etc.
That data can be converted programming object/variable into a file format like YAML,JSON,XML,binary file so it can be stored or send.
Example:-
Your Java Serialization Code:
import com.fasterxml.jackson.dataformat.yaml.YAMLMapper;
import java.io.File;
public class SimpleSerialize {
public static void main(String[] args) throws Exception {
User user = new User();
user.name = "Prasanth";
user.age = 24;
YAMLMapper mapper = new YAMLMapper();
mapper.writeValue(new File("user.yml"), user); // Serialization
}
}
Output in user.yml (YAML format):
reverse code YAML yo JAVA object = deserilation
What is Deserialization?
- Mean stored convert data format like YAML or JSON or XML(human readable format) back into java/python object or variable.
Example of YAML configuration:
server:
port: 8080
spring:
application:
name: MySpringBootApp
datasource:
url: jdbc:mysql://localhost:3306/mydb
username: user
password: password
logging:
level:
org.springframework: INFO
com.example.myapp: DEBUG
- YAML is a language to store and share data in a clean and readable format,used for configuration.
JSON
JSON-JavaScript Object Notation
- A lightweight, human-readable data format
- Commonly used for data exchange between client & server. for example spring Boot can automatically convert java object to Json responsce)(Serialization) and JSON to Java object(post)request input (Deserialization) using a library called Jackson by default.
- Spring Boot uses Jackson
Annotation Purpose
@RequestBody JSON → Java object (deserialization)
@ResponseBody Java object → JSON (serialization)
@RestController Combines @Controller + @ResponseBody
- Jackson default Json Processor it is auto configured.
Q1. How does Spring Boot handle JSON?
Using Jackson library (automatically)
Q2. How do you send/receive JSON in REST API? @RequestBody, @ResponseBody, or @RestController
Q3. How do you customize JSON fields? Use @JsonProperty, @JsonIgnore, etc.
Q4. What if the JSON format is wrong?
Spring throws HttpMessageNotReadableException
Important Points
- Jackson is auto-configured in Spring Boot → no setup needed.
- JSON input should match Java class field names (case-sensitive).
- Use validation annotations like @NotNull, @Size with @valid.
You can control JSON output with @JsonInclude, @JsonIgnore, etc.
Real-time use REST APIs, mobile/web apps
(frontend-backend data exchange)
Tomcat:-
Tomcat is server that run you java web application(WAR) also embedded(include) inside spring Boot Jar apps not java application((JAR)not need install server manually).
- Spring helps developer connect their web application to number data base.
- It support relational databases and non relational database
- What is a Relational Database (RDBMS)?
RDBS is a Structured data - it mean Data
mean:
- Data is Stored fixed format in tables(Column and rows) like Excel sheet.Every row must follow the same pattern. like Columns define the pattern(schema) so row must follow it and fill same columns with valid data. or you can not skip columns unless NULL is allowed or it has default value.Note you can not suddenly add 4 the value in the table ,that why structured .
- Uses Sql (structure Query language) to query and manage data
Example:-
CREATE TABLE student (
id INT,
name VARCHAR(50),
age INT DEFAULT 18
);
INSERT INTO student (id, name) VALUES (1, 'Prasanth');
if you try this ,it will fail
INSERT INTO students (id, name) VALUES (2, 'Rahul');
// because RDBMS is Structured data must fallow this rules(column(schema(rule)))the rows.

above the table:
- Every row must have 3 values: id, name, and age
- You can’t suddenly add a 4th value in one row
- You can’t skip columns unless NULL is allowed. This is called structured data.
Examples of RDBMS:
- MySQL
- PostgreSQL
- Oracle
- SQL Server
Real-World Use:
- Banking systems
- Employee or customer records
- E-commerce product databases
What is a Non-Relational Database (NoSQL)?
Stores data as:
- JSON-like documents (MongoDB)
- Key-value pairs (Redis)
- Graphs (Neo4j)
- Wide-columns (Cassandra)
Currently using Tools and version:-
Eclipse IDE - 2025-06
Java - Java 21 (LTS)
Springboot -3.5.3
Firefox -v140.0.2
Ubuntu -Ubuntu 22.04 LTS
Tomcat 10.1.42
Database -PostgreSQL 15+
How to add Third party jar add in you project ?
your project right click ,choose bulid path configure build path libraries class-path add-external Jar
How to inject dependency in pom.xml different way ?
https://mvnrepository.com/ you can search your required dependencies(version) paste you in pom.xml.
(Or)
install spring tool for Eclipse https://spring.io/tools( we will see later how to install and use)
(Or)
In Eclipse ->Help-> market place -> search spring latest version.
apachi poi => https://poi.apache.org/
Apachi poi is a Java library used to read, write, and modify data microsft office files and generate reports ,Automatic document like:
Excel (XLS/XLSX)
Word (DOC/DOCX)
PowerPoint (PPT/PPTX)
if you want your project you can add this dependencies based on project purpose or need.
Spring boot other some important point:
Spring boot
opinionated view of the Spring platform and third-party libraries so you can get started with minum fuses:- That mean
Spring Boot is opinionated framework , spring boot give default setup like (server(Tomcat),db,JSON..etc) setting,libraries,configurations..etc you can start with basic setup,so you don’t have to decide everything yourself create application faster with less configuration, best for beginners ,if you want decide everything yourself go to spring.
Features
- Create stand-alone Spring applications
- Embed Tomcat, Jetty or Undertow directly (no need to deploy WAR files)
- Provide opinionated 'starter' dependencies to simplify your build configuration
- Automatically configure Spring and 3rd party libraries whenever possible
- Provide production-ready features such as metrics, health checks, and externalized configuration
- Absolutely no code generation and no requirement for XML configuration

Finally we came conclusion part of this spring boot blog we will upcoming blog
spring boot projects to Travel...
W