Medicare Project Setup with Spring Boot

Business Scenario

In this lab, we will set up the foundation of the Medicare backend application using Java, Spring Boot, and Maven.

We will configure the Java environment, create and import the Spring Boot project, understand its structure and pom.xml.

Explore the role of the main application class and @SpringBootApplication.

Pre-Lab Preparation

Module:

1) Introduction to Spring Boot
2) Basic Spring data JPA and Rest APi

git pull origin branchName

Git Pull

Check Java

1

Phase 1 — Spring Boot Foundation

  • Open CMD/Terminal and run:

java -version

  • We want Java 21 installed
  • You can also check the compiler:

javac -version

  • If Java 21 is already configured, continue.

Create the Spring Boot project

2

Since your syllabus uses Eclipse + STS, we can use either:

  • For learning purposes, I prefer generating it through Spring Initializr first

Spring Initializr

Spring Starter Project option inside STS.

  • Use these values:

SettingsValues
ProjectMaven
LanguageJava
Spring Boot4.1.1
Groupcom.medicare
Artifactmedicare-backend
Namemedicare-backend
DescriptionBackend for Medicare Healthcare Management System
Package Namecom.medicare
PackagingJar
​Java21
  • Add only: Spring Web Dependency for now

Import into STS/Eclipse

3

  • After generating the project, Import it as:

Existing Maven Project

  • You should get something similar to:

medicare-backend/
├── src/
├── pom.xml
├── mvnw
└── mvnw.cmd

Keep the package structure simple

4

  • Right now, do not create ten empty folders.
  • We will create packages only when we need them.

com.medicare

│

├── MedicareBackendApplication.java

│

└── controller/

  • Currently we have:
com.medicare
│
├── controller/
├── service/
├── repository/
├── entity/
├── exception/
├── config/
└── security/
  • Later it will grow naturally into:
  • But those packages will appear during their relevant phases.
  • This keeps the beginner experience much cleaner.

Create our first controller

5

  • Inside: src/main/java/com/medicare create package:

com.medicare.controller

  • Inside the package create:

HealthController.java

  • Use this code:
package com.medicare.controller;
import java.util.Map;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/api")
public class HealthController {
    @GetMapping("/health")
    public Map<String, String> checkHealth() {
        return Map.of( "message", "Medicare Backend is running" );
    }
}

Run Medicare

6

  • Right-click on MedicareBackendApplication.java.

  • Select Run As.

  • Choose Spring Boot App.

  • Wait for the application to start.

Test using Postman

7

  • Open Postman
  • Select : GET
  • Enter:
http://localhost:8080/api/health
  • Then click send
  • Expected Response

{ 

"message": "Medicare Backend is running" 

}

  • Status:
200 OK

Checkpoint

Spring Boot project created

Maven project imported

controller package created

HealthController created

GET /api/health works

200 OK received

 

Great job!

You have successfully set up the Medicare Spring Boot project and created your first REST API.

Checkpoint

   Git Push

git push origin branchName

Next-Lab Preparation

Module:

1) Introduction to Spring Boot
2) Basic Spring data JPA and Rest APi