Skip to content

Aniket-Chugh/React-with-java-spring-boot-todo-web-app-java

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 

Repository files navigation

🚀 Java Spring Boot — My first ever web app with spring boot and these are the learnings :

🧩 Why Spring Boot?

✅ Simplifies backend creation

No more complex XML configuration like old Java Spring — everything is auto-configured.

✅ Handles dependencies automatically

Just declare what you need in the pom.xml, and Spring Boot will handle the rest.

✅ Integrates easily with databases

Works smoothly with MySQL, PostgreSQL, MongoDB, etc.

✅ REST API development made easy

You can create endpoints like /add, /get, /delete in just a few lines.


⚙️ Spring vs Spring Boot (Non-Tech Explanation)

Feature Spring (Old Way) Spring Boot (Modern Way)
⚙️ Setup Everything manual (XML, server, dependencies) Auto-configured and easy
🚀 Server You had to install Tomcat separately Comes with embedded Tomcat
📦 Dependencies Add one by one Comes pre-bundled with “starters”
💡 For beginners Complex Super beginner-friendly
⚡ Performance Slower setup Instant start with one command

👉 In short: Spring Boot = Spring + Simplicity + Power


🔌 Commonly Used Spring Boot Starters

Starter Name 2025 Status Purpose / Notes
spring-boot-starter-web ✅ Core For building REST APIs or MVC web apps — includes Spring MVC, Tomcat, and Jackson (JSON)
spring-boot-starter-data-jpa ✅ Standard For connecting to SQL databases using JPA (Hibernate)
spring-boot-starter-security ✅ Active For authentication and authorization
spring-boot-starter-test ✅ Essential Includes JUnit, Mockito, and Spring Test framework
spring-boot-starter-validation ✅ Used For validating user inputs in APIs

🪄 Step-by-Step Setup Guide

1️⃣ Install Tools

Tool Purpose Download
Java JDK 17+ Required for Spring Boot 3.x+ Download Here
IntelliJ IDEA (Community) Best IDE for Spring Boot Download Here
MySQL + MySQL Workbench Database Download Here
Postman (optional) Test your APIs Download Here

2️⃣ Create Your First Project (Using Spring Initializr)

Go to 👉 https://start.spring.io

  • Project: Maven
  • Language: Java
  • Spring Boot: Latest stable version (e.g., 3.5.x)
  • Group: com.todo
  • Artifact: todolist
  • Dependencies:
    • ✅ Spring Web
    • ✅ Spring Data JPA
    • ✅ MySQL Driver
    • ✅ Spring Boot DevTools

Click Generate, download ZIP → Extract it → open in IntelliJ IDEA.


3️⃣ Add MySQL Connector (If not added by Initializr)

🪄 Download the Connector:

  • Go to MySQL Connector/J
  • Choose “Platform Independent (.zip)”
  • Extract it → Find file mysql-connector-j-9.x.x.jar

💡 Add to IntelliJ:

  • Right-click your project → Open Module Settings
  • Go to Libraries → + → Java
  • Select the .jar file → Click Apply → OK

4️⃣ Configure Database in application.properties

spring.datasource.url=jdbc:mysql://localhost:3306/todolist spring.datasource.username=root spring.datasource.password=yourpassword spring.jpa.hibernate.ddl-auto=update spring.jpa.show-sql=true


5️⃣ Create a Simple To-Do REST API

Model:

@Entity
public class Task {
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;
    private String name;
    private boolean completed;

    // getters and setters
}

Annotation Meaning
@RestController Tells Spring this class handles HTTP requests (like API routes)
@RequestMapping Sets base path for APIs (e.g., /tasks)
@GetMapping Handles GET requests
@PostMapping Handles POST requests
@DeleteMapping Handles DELETE requests
@Autowired Automatically injects dependencies
@Entity Defines a database table
@Id Marks the primary key
@GeneratedValue Auto-increments IDs

🧠 FAQs (Must Know for Beginners) ❓What is a dependency?

A dependency is like a “plugin” or “tool” your app needs to run — Spring Boot downloads it automatically via Maven.

❓What is Maven?

Maven is a project manager for Java. It installs and manages all your dependencies (listed in pom.xml).

❓What is pom.xml?

Think of it as your project’s recipe file — it tells Spring Boot which libraries to use.

❓Why XML?

Old Spring used XML to manually configure beans, servers, etc. Spring Boot made this automatic using annotations instead.

❓What is Spring Initializr?

A website that auto-generates your Spring Boot project with all basic setup done.

❓Why IntelliJ IDEA?

Because IntelliJ detects Spring Boot projects automatically, shows annotations, and makes debugging easy.


⚡ Spring vs Spring Boot

Feature Spring (Traditional) Spring Boot (Modern)
🚀 Setup Time 30+ minutes 2 minutes
⚙️ Configuration Manual XML/Java config Auto-configured
🖥️ Server Setup Manual Tomcat installation Embedded Tomcat included
📦 Dependencies Add one by one Starters bundle everything
🎯 Beginner Friendly ❌ Complex ✅ Super Easy

1️⃣ Prerequisites Installation

Tool Purpose Download
Java JDK 17+ Runtime Environment Download Here
IntelliJ IDEA Best IDE for Spring Boot Download Here
MySQL + Workbench Database & GUI Tool Download Here
Postman API Testing Download Here

🔧 application.properties Configuration

# Database Configuration
spring.datasource.url=jdbc:mysql://localhost:3306/todolist
spring.datasource.username=root
spring.datasource.password=yourpassword

# JPA Configuration
spring.jpa.hibernate.ddl-auto=update
spring.jpa.show-sql=true
spring.jpa.properties.hibernate.format_sql=true

# Server Configuration
server.port=8080
spring.application.name=todo-app

# Logging
logging.level.com.todo=DEBUG
logging.level.org.hibernate.SQL=DEBUG

🧩 Essential Annotations

Annotation Purpose Example
@SpringBootApplication Main application entry point ```java @SpringBootApplication public class App { public static void main(String[] args) { SpringApplication.run(App.class, args); } } ```
@RestController API controller (returns JSON) ```java @RestController @RequestMapping("/api") public class TaskController { @GetMapping("/tasks") public List getTasks() { return taskService.getAllTasks(); } } ```
@Service Business logic layer ```java @Service public class TaskService { // Business methods here } ```
@Repository Data access layer ```java @Repository public interface TaskRepository extends JpaRepository { } ```
@Entity Database table mapping ```java @Entity public class Task { @Id private Long id; private String title; } ```
@Autowired Dependency injection ```java @Autowired private TaskRepository taskRepository; ```

🛠️ Essential IntelliJ Plugins

Plugin Purpose Installation
Lombok Reduces boilerplate code Settings → Plugins → Lombok
Spring Boot Assistant Enhanced Spring support Marketplace → "Spring Boot"
Rainbow Brackets Colorful bracket matching Marketplace → "Rainbow Brackets"
GitToolBox Git enhancements Marketplace → "GitToolBox"

⚡ Useful Maven Commands

# Run application
mvn spring-boot:run

# Run tests
mvn test

# Clean and build
mvn clean install

# Create executable JAR
mvn clean package

# Run with specific profile
mvn spring-boot:run -Dspring-boot.run.profiles=dev

Happy Coding! 💻✨

Command Description
mvn spring-boot:run Run the app
mvn clean install Clean and rebuild
Ctrl + Shift + F10 Run current class in IntelliJ
Ctrl + Space IntelliJ autocomplete

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors