0
0
Spring Bootframework~30 mins

Running a Spring Boot application in Spring Boot - Mini Project: Build & Apply

Choose your learning style9 modes available
Running a Spring Boot Application
📖 Scenario: You want to create a simple Spring Boot application that starts up and shows a welcome message on the home page. This is like opening a shop and putting a welcome sign on the door.
🎯 Goal: Build a minimal Spring Boot application that runs and displays "Welcome to Spring Boot!" on the home page.
📋 What You'll Learn
Create a Spring Boot main application class with the correct annotation
Add a configuration variable for the welcome message
Create a controller with a method to handle the home page request
Complete the application by running it with the Spring Boot run method
💡 Why This Matters
🌍 Real World
Spring Boot is widely used to build web applications and REST APIs quickly. Knowing how to run a basic app is the first step to creating real services.
💼 Career
Many Java developer jobs require knowledge of Spring Boot to build and maintain backend services. This project teaches the essential startup pattern.
Progress0 / 4 steps
1
Create the Spring Boot main application class
Create a class called DemoApplication in package com.example.demo. Add the @SpringBootApplication annotation and a main method that calls SpringApplication.run(DemoApplication.class, args).
Spring Boot
Need a hint?

Use @SpringBootApplication on the class and a main method that calls SpringApplication.run.

2
Add a configuration variable for the welcome message
Inside the DemoApplication class, add a public static final String variable called WELCOME_MESSAGE and set it to "Welcome to Spring Boot!".
Spring Boot
Need a hint?

Define a public static final String named WELCOME_MESSAGE with the exact text.

3
Create a controller to handle the home page request
Create a new class called HomeController in package com.example.demo. Add the @RestController annotation. Add a method called home that returns the DemoApplication.WELCOME_MESSAGE string. Annotate this method with @GetMapping("/").
Spring Boot
Need a hint?

Use @RestController on the class and @GetMapping("/") on the method that returns the welcome message.

4
Run the Spring Boot application
Ensure the DemoApplication class has the main method that calls SpringApplication.run(DemoApplication.class, args). This method starts the application.
Spring Boot
Need a hint?

The main method must call SpringApplication.run to start the app.