Spring Boot Hello World using STS

Spring Boot Hello World Example Using STS (2026)

Spring Boot Hello World Example Using STS

In this tutorial, you will learn how to build a Spring Boot Hello World application using Spring Tool Suite (STS). You will download STS, create a Spring Starter Project with the Spring Web dependency, add a @RestController, and run your first REST endpoint.

Download and Install STS

First, download STS from the official Spring website:

Download Spring Tool Suite (STS) from spring.io/tools

Spring Tool Suite download page on spring.io/tools
Spring Tool Suite download page.

Download and install it on your machine, then launch STS.

Spring Tool Suite launcher window
Spring Tool Suite launcher after installation.

Choose a Workspace

Select or create a workspace directory where your projects will be stored.

Workspace selection dialog in Spring Tool Suite
Selecting the workspace directory.

Create a Spring Starter Project

From the File menu, choose New → Spring Starter Project.

New Spring Starter Project menu in STS
Creating a new Spring Starter Project.

Configure Project Metadata

Enter your project details such as name, artifact-id, group-id, type, packaging, and Java version.

Spring Starter Project metadata configuration form
Configuring Spring Starter Project metadata.

Add Spring Web Dependency

On the dependencies screen, select Spring Web. This brings in Spring MVC and an embedded Tomcat server.

Selecting Spring Web dependency in Spring Starter Project
Selecting the Spring Web dependency.

When you click Finish, make sure you have a stable internet connection because Maven downloads dependencies from the remote repository into your local repository.

Generated Project Structure

STS will generate the default project structure and code.

Generated Spring Boot project structure in STS
Generated Spring Boot project structure.

Open FirstExampleApplication.java. It will look like this:

package com.deepsingh44.demo;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
public class FirstExampleApplication {

    public static void main(String[] args) {
        SpringApplication.run(FirstExampleApplication.class, args);
    }

}

Create HelloController

Create a new class named HelloController.java inside the same package:

package com.deepsingh44.demo;

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

@RestController
public class HelloController {

    @GetMapping("/")
    public String helloWorld() {
        return "Hello First Program";
    }

}

Run the Application

Right-click your project and choose Run As → Spring Boot App.

Run As Spring Boot App context menu in STS
Running the project as a Spring Boot App.

Fix Port 8080 Conflict

If your application shows an error that port 8080 is already in use:

Spring Boot error port 8080 already in use
Port 8080 conflict error in the console.

Change the port number in src/main/resources/application.properties:

server.port=8888

See the Result

Run the application again. It will start successfully:

Spring Boot application started successfully on port 8888
Spring Boot started on port 8888.

Open any browser and visit:

Browser showing Hello First Program from Spring Boot endpoint
Browser displaying the "Hello First Program" response.

You should see Hello First Program in your browser.

Frequently Asked Questions

What is Spring Boot?

Spring Boot is an opinionated extension of the Spring Framework that removes boilerplate configuration. It provides auto-configuration, embedded servers, and production-ready features so you can create stand-alone Java applications quickly.

What is STS in Spring Boot?

STS stands for Spring Tool Suite, an Eclipse-based IDE tuned for Spring projects. It includes Spring-aware tooling, project templates, and a built-in Spring Starter wizard.

Why am I getting "port 8080 was already in use" in Spring Boot?

Another process is already using port 8080. You can either stop that process or change the port by adding server.port=8888 in src/main/resources/application.properties.

What is the difference between @Controller and @RestController?

@Controller is used for traditional Spring MVC and returns view names. @RestController is a convenience annotation that combines @Controller and @ResponseBody, so each method returns data directly as JSON or plain text.

Which dependency do I need for a Spring Boot REST API?

Add the Spring Web dependency in Spring Initializr or Spring Starter Project. It brings in Spring MVC and an embedded Tomcat server so you can expose REST endpoints.

Conclusion

In this tutorial, you built your first Spring Boot Hello World application using STS. You downloaded Spring Tool Suite, created a Spring Starter Project with Spring Web, added a @RestController, handled the port 8080 conflict, and confirmed the endpoint in your browser.

Related topics: Spring Boot REST API, Spring Boot Annotations, Spring Web Dependency, Spring Starter Project, Embedded Tomcat, Spring Boot Application Properties

No comments: