Abdallah Benyounes
3 min readJan 20, 2023

Getting Started with Spring Boot: A Step-by-Step Guide to Installation and Project Creation

Spring Boot is a popular framework for building web applications in Java. In this tutorial, we will show you how to create a new Spring Boot project by using the Spring Initializer website (https://start.spring.io/) or the Spring Boot CLI on Windows, Linux, and Mac OS. We will also cover the installation of Spring Boot on all three operating systems with examples for each step.

Steps for installing Spring Boot on Windows:

  1. Ensure that you have JDK 8 or later installed on your Windows machine. You can check the version by running the command java -version in Command Prompt. Example output: "java version "1.8.0_271"

Command:

C:/...> spring --version

Output:

C:/...>java  version 1.8.0_271
  1. Download the Spring Boot CLI for Windows from the official website (https://repo.spring.io/release/org/springframework/boot/spring-boot-cli/2.5.2/spring-boot-cli-2.5.2-bin.zip)
  2. Extract the downloaded file to the desired location (e.g. C:\spring-2.5.2).
  3. Add the Spring Boot CLI bin folder to your system’s PATH by following these instructions:
  • Right-click on This PC or My Computer, then select Properties.
  • Click on Advanced system settings.
  • Click on Environment Variables.
  • Under System Variables, scroll down and find the Path variable, then click on Edit.
  • Click on New and add the path to the Spring Boot CLI bin folder (e.g. C:\spring-2.5.2\bin)

5. Verify the installation by opening a new Command Prompt window and running the command spring --version. Example output: "Spring Boot v2.5.2"

Command:

PathToSpringBootProject> spring --version

Output:


PathToSpringBootProject> Spring Boot v2.5.2

Steps for creating a new Spring Boot project through the Spring Initializer website:

  1. Go to https://start.spring.io/
  1. Select the latest stable version of Spring Boot. Example: “2.5.2”
  2. Choose the type of project you want to create (e.g. Maven or Gradle project). Example: “Maven Project”
  3. Select the dependencies you want to include in your project (e.g. Spring Web, Spring Data JPA). Example: “Spring Web” and “Spring Data JPA”
  4. Click the “Generate” button to download a zip file containing the project.
  5. Unzip the project and import it into your preferred development environment (e.g. Eclipse, IntelliJ IDEA ).
  1. Run the application by using the command “./mvnw spring-boot:run” in the project folder (if maven is selected) or “./gradlew bootRun” in the project folder (if gradle is selected). Example: “./mvnw spring-boot:run”

Command(if maven is selected):

PathToSpringBootProject>./mvnw spring-boot:run

Command(if gradle is selected):

PathToSpringBootProject>./gradlew bootRun

Steps for creating a new Spring Boot project using the Spring Boot CLI:

  1. Open a terminal window and navigate to the directory where you want to create your project. Example: “cd Documents”

Command:

DirectoryToSpringBootProject> cd Documents
  1. Run the command “spring init — dependencies=web myproject” to create a new Spring Boot project with the web dependency.

Command:

Documents> spring init - dependencies=web myproject
  1. Change directory to myproject folder using command “cd myproject”

Command:

Documents> cd myproject

Run the application by using the command “./mvnw spring-boot:run” if maven is selected or “./gradlew bootRun” if gradle is selected. Example: “./mvnw spring-boot:run”

Conclusion:

Installing Spring Boot on Windows, Linux, and Mac OS is a straightforward process, and the Spring Initializer website and Spring Boot CLI make it easy to create a new Spring Boot project on any operating system. With this tutorial, you now have the knowledge and examples to set up a Spring Boot project on your preferred operating system and start building your web application. Spring Boot is a powerful framework that can help you develop web applications quickly and easily, providing a variety of features out of the box. Don’t hesitate to explore its features and use them to improve your application. Remember to keep your Spring Boot version up-to-date to enjoy the latest improvements and bug fixes.

Abdallah Benyounes

Experienced full-stack Senior Java/Angular developer more than 10 years of experience in various industries including Banking, OilandGas, and the EU Parliament.