Spring Tool Suite 4 (STS) is a powerful IDE designed specifically for Spring developers. It makes it easy to build Spring applications by providing features like code suggestions, built-in templates, and integration with Spring Boot. In this guide, we’ll explain how to install STS on Windows 11 and create your first Spring Boot project with simple REST API.
YouTube Video
We recommend watching the YouTube video below to learn how to install the Spring Tool Suite 4 (STS) IDE step-by-step on Windows 11 and create a simple Spring Boot project with the REST API.
Why Use Spring Tool Suite 4?
- Spring Boot Integration: STS simplifies the process of creating Spring Boot projects.
- Developer-Friendly: It offers code navigation, debugging tools, and built-in support for Spring Framework.
- Free and Open Source: STS is free to use and maintained by the creators of Spring.
Step 1: Download Spring Tool Suite 4 (STS)
- Open your browser and visit the official Spring Tool Suite download page.
- Scroll down to find the Spring Tools 4 for Eclipse section.
- Select the version for Windows x64.
- Click the Download button to start downloading the ZIP file.
Step 2: Install Spring Tool Suite 4
- After the ZIP file is downloaded, locate it in your Downloads folder.
- Extract the ZIP file by right-clicking on it and selecting Extract All.
- Choose a folder to extract the files (e.g.,
C:\STS4
). - Navigate to the extracted folder and double-click the
SpringToolSuite4.exe
file to launch STS.
Step 3: Set Up Spring Tool Suite Workspace
- When STS opens for the first time, it will prompt you to select a workspace.
- The workspace is where all your Spring projects will be stored.
- Use the default path or specify a custom folder and click Launch.
Step 4: Install Java Development Kit (JDK)
- Ensure you install the latest Java Development Kit (JDK 23) on your system.
- If you still need to, check out our Java JDK 23 installation guide.
- Verify your JDK setup:
- Open the Command Prompt.
- Run
java -version
. You should see the JDK version.
Step 5: Create Your First Spring Boot Project
Step 5.1: Start a New Spring Boot Project
- In STS, click on File > New > Spring Starter Project.
- Fill in the details:
- Project Name: Enter
HelloSpringBoot
. - Type: Maven (default).
- Packaging: Jar.
- Java Version: Ensure it matches your JDK version (e.g., 17 or 23).
- Project Name: Enter
- Click Next.
Step 5.2: Add Dependencies
- In the next window, select the dependencies you need. For a simple project, choose:
- Spring Web: For building REST APIs.
- Click Finish to create the project.
Step 5.3: Explore the Project Structure
- STS will generate a project structure with key folders like:
- src/main/java: Contains your Java code.
- src/main/resources: Contains configuration files like
application.properties
.
- Open the
HelloSpringBootApplication.java
file in the src/main/java folder.
Step 5.4: Write Your First Spring Boot Application
Update the
HelloSpringBootApplication.java
file as follows:package com.example.hellospringboot; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RestController; @SpringBootApplication @RestController public class HelloSpringBootApplication { public static void main(String[] args) { SpringApplication.run(HelloSpringBootApplication.class, args); } @GetMapping("/") public String hello() { return "Welcome to Spring Boot!"; } }
Save the file by pressing Ctrl + S.
Step 5.5: Run Your Spring Boot Application
- Right-click on the project in the Package Explorer.
- Select Run As > Spring Boot App.
- STS will start your application, and you’ll see logs in the Console window.
Step 5.6: Test Your Application
- Open your browser and navigate to
http://localhost:8080
. - You should see the message:
Welcome to Spring Boot!
Troubleshooting Tips
- Java Not Found: Ensure the JDK path is correctly set in the
JAVA_HOME
environment variable. - STS Not Launching: Make sure you’ve downloaded the correct version for Windows x64 and extracted the files properly.
- Port Already in Use: Change the default port by adding
server.port=8081
to theapplication.properties
file.
Conclusion
Congratulations! You’ve successfully installed Spring Tool Suite 4 on Windows 11 and created your first Spring Boot project. With STS, developing Spring applications becomes much easier and more efficient. Keep exploring its features, and enjoy building powerful Java applications. Happy coding!
Comments
Post a Comment
Leave Comment