Spring Boot Tutorial

Spring Boot - Software Setup and Configuration (STS/Eclipse/IntelliJ)

Prerequisite (Spring Core Concepts)

Spring Boot Core

Spring Boot with REST API

Spring Boot with Database and Data JPA

Spring Boot with Kafka

Spring Boot with AOP

How to Run Your First Spring Boot Application in Spring Tool Suite?

Spring Tool Suite (STS) is an Integrated Development Environment (IDE) tailored specifically for Spring development. Running a Spring Boot application in STS is quite straightforward.

Follow these steps to run your first Spring Boot application in Spring Tool Suite:

1. Install Spring Tool Suite:

If you haven't installed it yet:

  • Download the latest version of STS from the Spring website.
  • Extract the downloaded ZIP file to a suitable location on your machine.
  • Run the SpringToolSuite4 executable.

2. Create a New Spring Boot Project:

  • Click on File -> New -> Spring Starter Project.
  • In the "New Spring Starter Project" dialog:
    • Fill in the "Name" and other metadata.
    • Click "Next".
  • Choose the required dependencies. For a simple web application, choose "Web" -> "Spring Web".
  • Click "Finish".

STS will generate a Spring Boot project with the selected dependencies.

3. Create a Simple Controller:

Now, let's create a simple controller:

  • In the main package, right-click and choose New -> Class.
  • Name it HelloController and click "Finish".
  • Add the following content to the class:
package com.example.demo;

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

@RestController
public class HelloController {

    @GetMapping("/hello")
    public String sayHello() {
        return "Hello, Spring Boot!";
    }
}

4. Run Your Application:

  • Navigate to the main class (usually named YourProjectNameApplication and has the @SpringBootApplication annotation).
  • Right-click on the file.
  • Choose "Run As" -> "Spring Boot App".

STS will start your application. You'll know it's running when you see log entries in the console, including a line that looks like:

Started YourProjectNameApplication in X seconds (JVM running for Y)

5. Access Your Application:

Once the application starts successfully, open a web browser and navigate to:

http://localhost:8080/hello

You should see the message "Hello, Spring Boot!"

Congratulations! You've just run your first Spring Boot application in Spring Tool Suite. As with any IDE, the more you use STS, the more familiar you'll become with its features and shortcuts.