Skip to main content

Command Palette

Search for a command to run...

#4 Understanding the Java Stack: JSE → Advanced Java → Maven → Spring Boot

Updated
4 min read
#4 Understanding the Java Stack: JSE → Advanced Java → Maven → Spring Boot

JSE (Core Java) – The Foundation

What is JSE?

Java Standard Edition provides:

  • OOP concepts

  • Collections

  • Exception handling

  • Multithreading

  • File handling

Without Core Java:
You cannot understand Spring annotations, beans, or dependency injection.

Spring internally uses:

  • Interfaces

  • Reflection

  • Annotations

  • Collections

  • Exception handling

So Core Java = mandatory base layer


Advanced Java – Web & Database Layer

Now we move from standalone apps → web apps.

Advanced Java mainly includes:

  • JDBC

  • Servlets

  • JSP


JDBC (Java Database Connectivity)

Used to:

  • Connect Java application to database

  • Execute SQL queries

  • Perform CRUD operations

Example:

Connection con = DriverManager.getConnection(...);
PreparedStatement ps = con.prepareStatement("select * from users");

Problem with JDBC:

  • Too much boilerplate

  • Manual connection handling

  • Manual exception handling

Spring Boot replaces JDBC complexity using:

  • Spring Data JPA

  • Hibernate


Servlets

Servlets handle:

  • HTTP requests

  • HTTP responses

Basic flow:

Browser → Servlet → Business Logic → Database → Response → Browser

Problems:

  • Manual configuration

  • XML heavy

  • Hard to maintain

  • Large web.xml files

Spring Boot simplifies this using:

  • @RestController

  • @RequestMapping

  • Auto configuration


JSP (Java Server Pages)

Used to:

  • Generate dynamic HTML

  • Mix Java code with HTML

Problems:

  • Mixing Java + HTML = messy

  • Hard to maintain

  • Not REST friendly

Modern apps use:

  • React / Angular frontend

  • Spring Boot backend (REST APIs)

Build Tools

Now imagine:

Your project needs:

  • Spring libraries

  • Hibernate

  • MySQL driver

  • Logging framework

  • JSON library

Manually downloading JAR files? Impossible for real projects.

That’s why we use Build Tools.


What is a Build Tool?

A build tool:

  • Manages dependencies

  • Downloads required libraries

  • Compiles code

  • Packages application

  • Runs tests

Common build tools:

  • Maven

  • Gradle

We will use Maven.


Why Do We Need Maven?

Without Maven:

  • Manually download 50+ JAR files

  • Manage versions yourself

  • Resolve conflicts manually

With Maven:

  • Just declare dependency

  • Maven downloads everything automatically

Example:

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-web</artifactId>
</dependency>

Maven will:

  • Download Spring

  • Download embedded Tomcat

  • Download JSON converter

  • Download logging framework

One line → complete ecosystem

What is pom.xml?

POM = Project Object Model

It is the heart of Maven project.

It contains:

  • Project metadata

  • Dependencies

  • Build configuration

  • Plugins

Example structure:

<project>
   <groupId>com.example</groupId>
   <artifactId>demo</artifactId>
   <version>1.0</version>

   <dependencies>
       ...
   </dependencies>
</project>

Think of pom.xml as Instruction file for Maven.


JDK, Maven, IDE (JDE) – How They Connect

JDK (Java Development Kit)

Provides:

  • javac (compiler)

  • java (runtime)

  • JVM

Used to:

  • Compile Java code

  • Run Java applications

Without JDK → nothing runs.


Maven

Uses JDK to:

  • Compile project

  • Build project

  • Create .jar file

Command:

mvn clean install

This:

  • Compiles

  • Tests

  • Packages application


IDE (Eclipse / IntelliJ)

IDE is just:

  • Code editor

  • UI wrapper around Maven

  • Makes development easy


Dependency Management & Maven Relationship


What is Dependency?

A dependency is any external library your project needs to work.

Example:

  • Spring Framework

  • Hibernate

  • MySQL Driver

  • Jackson (JSON)

  • JUnit (Testing)

Instead of writing everything from scratch, we use ready-made libraries.


What is Dependency Management?

Dependency Management means:

  • Adding required libraries

  • Managing their versions

  • Handling library conflicts

  • Downloading transitive dependencies automatically

  • Updating dependencies safely

In simple words:

Dependency Management = Managing external libraries properly.


Problem Without Dependency Management

Imagine you need:

  • spring-web

  • spring-core

  • logback

  • mysql driver

Without a tool:

Manually download each JAR
Add to project manually
Manage versions manually
If version conflicts happen → You fix manually
Very messy in large projects

For enterprise projects with 100+ dependencies, this is impossible.

How Maven Solves This

Maven is a build tool that handles dependency management automatically.

When you write this in pom.xml:

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-web</artifactId>
</dependency>

Maven will:

Download required JAR
Download its dependent libraries (transitive dependencies)
Store them in local repository (.m2 folder)
Resolve version conflicts
Add them to classpath automatically


What Are Transitive Dependencies?

If A depends on B
And B depends on C

When you add A, Maven automatically downloads:

A + B + C

You don't need to add everything manually.

This is called:

Transitive Dependency Management


Where Does Maven Download Dependencies From?

Maven downloads from:

  • Maven Central Repository (default)

  • Remote repositories

  • Company private repositories

And stores them in:

C:\Users\YourName\.m2\repository

Version Conflict Handling

Sometimes:

Library A needs version 1.0
Library B needs version 2.0

Maven uses:

"Nearest definition wins" rule
Or explicitly defined version in pom.xml

You can override version manually if needed.


Dependency Management in Spring Boot

Spring Boot improves Maven dependency management even more using:

Parent POM
Dependency Management Section

Example:

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
</parent>

Now you don’t need to write versions manually.

Spring Boot already manages compatible versions for:

  • Spring

  • Hibernate

  • Jackson

  • Logging

  • Tomcat

This avoids version mismatch issues.