A Step-by-Step Guide to Building Your First Java App with Spring Boot.

Why Spring Boot?

Spring Boot has become one of the most popular Java frameworks for building enterprise-grade applications. It simplifies Java development by removing boilerplate configuration, allowing developers to focus on writing business logic.

Whether you’re a beginner or transitioning into Java from another language, Spring Boot is your fast-track to creating secure, scalable web applications β€” and this guide will show you how.


Prerequisites

Before we dive in, make sure you have the following:

  • Java 17 or 21 installed
  • Maven or Gradle (Java build tools)
  • An IDE like IntelliJ IDEA, Eclipse, or VS Code
  • Internet connection to download Spring dependencies

Step 1: Initialize the Project

Go to https://start.spring.io

Choose the following options:

  • Project: Maven or Gradle
  • Language: Java
  • Spring Boot Version: 3.x
  • Group: com.mahquests
  • Artifact: first-java-app
  • Dependencies: Spring Web, Spring Boot DevTools, Spring Data JPA, H2 Database (for testing)

Then click β€œGenerate” β€” this downloads a .zip file containing your new project.


Step 2: Unzip and Open in IDE

  • Extract the .zip file
  • Open the folder in your IDE (e.g., IntelliJ or Eclipse)
  • Wait for the build tool (Maven/Gradle) to download dependencies

Step 3: Build Your First REST Controller

Inside src/main/java/com/mahquests/firstjavaapp, create a new Java class:

package com.mahquests.firstjavaapp;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class HelloController {

@GetMapping("/hello")
public String sayHello() {
    return "Welcome to Your First Spring Boot App!";
}

}Step 4: Run the Application

Open FirstJavaAppApplication.java (your main entry point):

javaCopyEdit@SpringBootApplication
public class FirstJavaAppApplication {
    public static void main(String[] args) {
        SpringApplication.run(FirstJavaAppApplication.class, args);
    }
}

Run the application. Once it starts, visit:
🌐 http://localhost:8080/hello

You should see:
βœ… “Welcome to Your First Spring Boot App!”Step 4: Run the Application

Open FirstJavaAppApplication.java (your main entry point):

javaCopyEdit@SpringBootApplication
public class FirstJavaAppApplication {
    public static void main(String[] args) {
        SpringApplication.run(FirstJavaAppApplication.class, args);
    }
}

Run the application. Once it starts, visit:
🌐 http://localhost:8080/hello

You should see:
βœ… “Welcome to Your First Spring Boot App!”Step 4: Run the Application

Open FirstJavaAppApplication.java (your main entry point):

javaCopyEdit@SpringBootApplication
public class FirstJavaAppApplication {
    public static void main(String[] args) {
        SpringApplication.run(FirstJavaAppApplication.class, args);
    }
}

Run the application. Once it starts, visit:
🌐 http://localhost:8080/hello

You should see:
βœ… “Welcome to Your First Spring Boot App!”Step 4: Run the Application

Open FirstJavaAppApplication.java (your main entry point):

javaCopyEdit@SpringBootApplication
public class FirstJavaAppApplication {
    public static void main(String[] args) {
        SpringApplication.run(FirstJavaAppApplication.class, args);
    }
}

Run the application. Once it starts, visit:
🌐 http://localhost:8080/hello

You should see:
βœ… “Welcome to Your First Spring Boot App!”Step 4: Run the Application

Open FirstJavaAppApplication.java (your main entry point):

javaCopyEdit@SpringBootApplication
public class FirstJavaAppApplication {
    public static void main(String[] args) {
        SpringApplication.run(FirstJavaAppApplication.class, args);
    }
}

Run the application. Once it starts, visit:
🌐 http://localhost:8080/hello

You should see:
βœ… “Welcome to Your First Spring Boot App!”Step 4: Run the Application

Open FirstJavaAppApplication.java (your main entry point):

javaCopyEdit@SpringBootApplication
public class FirstJavaAppApplication {
    public static void main(String[] args) {
        SpringApplication.run(FirstJavaAppApplication.class, args);
    }
}

Run the application. Once it starts, visit:
🌐 http://localhost:8080/hello

You should see:
βœ… “Welcome to Your First Spring Boot App!”Step 4: Run the Application

Open FirstJavaAppApplication.java (your main entry point):

javaCopyEdit@SpringBootApplication
public class FirstJavaAppApplication {
    public static void main(String[] args) {
        SpringApplication.run(FirstJavaAppApplication.class, args);
    }
}

Run the application. Once it starts, visit:
🌐 http://localhost:8080/hello

You should see:
βœ… “Welcome to Your First Spring Boot App!”Step 4: Run the Application

Open FirstJavaAppApplication.java (your main entry point):

javaCopyEdit@SpringBootApplication
public class FirstJavaAppApplication {
    public static void main(String[] args) {
        SpringApplication.run(FirstJavaAppApplication.class, args);
    }
}

Run the application. Once it starts, visit:
🌐 http://localhost:8080/hello

You should see:
βœ… “Welcome to Your First Spring Boot App!”Step 4: Run the Application

Open FirstJavaAppApplication.java (your main entry point):

javaCopyEdit@SpringBootApplication
public class FirstJavaAppApplication {
    public static void main(String[] args) {
        SpringApplication.run(FirstJavaAppApplication.class, args);
    }
}

Run the application. Once it starts, visit:
🌐 http://localhost:8080/hello

You should see:
βœ… “Welcome to Your First Spring Boot App!”Step 4: Run the Application

Open FirstJavaAppApplication.java (your main entry point):

javaCopyEdit@SpringBootApplication
public class FirstJavaAppApplication {
    public static void main(String[] args) {
        SpringApplication.run(FirstJavaAppApplication.class, args);
    }
}

Run the application. Once it starts, visit:
🌐 http://localhost:8080/hello

You should see:
βœ… “Welcome to Your First Spring Boot App!”

Step 5: Add a Data Layer (Bonus Step)

Want to make your app more dynamic?

Create a Student Entity:

javaCopyEdit@Entity
public class Student {
    @Id
    @GeneratedValue
    private Long id;

    private String name;
}

Create a Repository:

javaCopyEditpublic interface StudentRepository extends JpaRepository<Student, Long> {
}

Spring Boot automatically provides CRUD operations β€” no implementation needed!


Real-World Relevance

What you just built is the foundation of most enterprise applications:

  • Financial APIs for transactions
  • Government data services
  • HR & compliance systems
  • Telecom user management platforms

That’s why companies still trust Java and Spring Boot to run their critical operations β€” and why Java skills are in demand in 2025.


Learn Java the Right Way β€” With Mah Quests Enterprises

We don’t just teach Java β€” we teach how to apply Java in real-world, regulated industries like banking, insurance, and telecom.

Our training includes:
βœ… Java 21 + Spring Boot
βœ… Hands-on labs and use cases
βœ… POPIA-compliant coding patterns
βœ… Secure app development


πŸ“© Ready to Build Your Skills?

Join our Java for Financial Services: Compliance and Security course β€” or contact us to upskill your dev team.

πŸ“§ hello@mahquests.co.za
🌐 www.mahquests.co.za

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top