Spring Framework Tutorial

Software Setup and Configuration (STS/Eclipse/IntelliJ)

Core Spring

Spring Annotations

Spring Data

Spring JDBC

Spring Security

How to Create and Setup Spring Boot Project in Spring Tool Suite?

Spring Tool Suite (STS) is an Eclipse-based IDE designed specifically for Spring development, making it easier to create and manage Spring Boot projects. Here's a step-by-step guide to setting up a Spring Boot project in STS:

1. Launch Spring Tool Suite (STS):

Start the STS IDE. If it's your first time, you'll be prompted to select a workspace location. The workspace is the directory where your projects will be stored.

2. Create a New Spring Starter Project:

  • Click on File in the top menu.
  • Choose New > Spring Starter Project.

3. Fill in the Project Details:

In the New Spring Starter Project dialog, you'll be prompted to provide:

  • Name: The name of your project.

  • Type: Choose the build tool (Maven or Gradle). Maven is commonly used.

  • Packaging: JAR (recommended for Spring Boot) or WAR.

  • Java Version: Choose the Java version you want to use.

  • Language: Java, Kotlin, or Groovy. Java is most common.

  • Group: Base package for your project, typically in the format of com.example.

  • Artifact: A unique ID for your project.

  • Version: Project version.

  • Description: Brief description of your project.

  • Package: Package structure for your main application, which is typically derived from the Group and Artifact values.

  • Click Next.

4. Select Starter Dependencies:

In the next window, you can choose the Spring Boot Starter dependencies you'd like to include in your project:

  • For a basic web application, you might select Spring Web.
  • For using JPA with databases, you might select Spring Data JPA.
  • If you plan to develop a REST API, you might choose Spring HATEOAS.
  • For testing, Spring Boot Starter Test will usually be included by default.

Search for and check the desired dependencies.

  • Click Next.

5. Review and Complete the Setup:

Review your project details and the selected dependencies. If everything looks good:

  • Click Finish.

STS will now generate the Spring Boot project structure and pull in the necessary dependencies from the Maven Central Repository or the specified repositories for Gradle.

6. Project Structure:

In the Project Explorer or Package Explorer, you'll see your new project. It will have a standard Spring Boot structure. Inside the src/main/java directory, you'll find the main application class marked with @SpringBootApplication. This class serves as the entry point to your Spring Boot application.

7. Running the Application:

  • Right-click on the main application class.
  • Choose Run As > Spring Boot App.

Once running, if you added the Spring Web dependency, your application would be accessible at http://localhost:8080.

That's it! You've successfully set up a Spring Boot project in Spring Tool Suite. You can now start adding your business logic, controllers, services, and other components as required by your application.