How to Create a Spring Boot Project in IntelliJ IDEA (Free Community Edition)

🎓 Top 15 Udemy Courses (80-90% Discount): My Udemy Courses - Ramesh Fadatare — All my Udemy courses are real-time and project oriented courses.

▶️ Subscribe to My YouTube Channel (178K+ subscribers): Java Guides on YouTube

▶️ For AI, ChatGPT, Web, Tech, and Generative AI, subscribe to another channel: Ramesh Fadatare on YouTube

Spring Boot makes Java application development simple and efficient. With Spring Initializr, you can quickly set up a project, and using the free IntelliJ IDEA Free Community Edition, you can start coding immediately. In this guide, we’ll show you how to create a Spring Boot project, import it into IntelliJ IDEA, and build a simple REST API.

YouTube Video

We recommend watching the YouTube video below to learn how to create a Spring Boot project in IntelliJ IDEA (Free Community Edition) IDE using Spring Initializr and build Spring Boot REST API:

What You’ll Need

  1. Java Development Kit (JDK 23):
    Download and install JDK 23 from Oracle or OpenJDK.

    • Verify the installation:
      java -version
      
  2. IntelliJ IDEA Community Edition:
    Download the free version of IntelliJ IDEA from JetBrains.

Step 1: Create a Spring Boot Project with Spring Initializr

  1. Visit Spring Initializr:
    Go to Spring Initializr in your web browser.

  2. Fill in Project Details:

    • Group: com.example
    • Artifact: spring-boot-rest-api
    • Name: SpringBootRestApi
    • Packaging: Jar
    • Java Version: 23
  3. Add Dependencies:

    • Click Add Dependencies and select:
      • Spring Web: To build REST APIs.
      • Spring Boot DevTools: For hot-reloading during development.
  4. Download the Project:

    • Click Generate to download the project as a ZIP file.
  5. Extract the ZIP File:
    Extract the downloaded project to a folder (e.g., C:\Projects\SpringBootRestApi).

Step 2: Open the Project in IntelliJ IDEA

  1. Launch IntelliJ IDEA:

    • Open IntelliJ IDEA Community Edition.
  2. Open the Project:

    • From the IntelliJ welcome screen, click Open.
    • Navigate to the folder where you extracted the Spring Boot project and select it.
  3. Wait for Dependencies:

    • IntelliJ will automatically detect the pom.xml file (Maven project) and download the necessary dependencies.

Step 3: Explore the Project Structure

Your project will look something like this:

spring-boot-rest-api/
├── src/
│   ├── main/
│   │   ├── java/com/example/springbootrestapi/
│   │   │   └── SpringBootRestApiApplication.java
│   │   └── resources/
│   │       ├── application.properties
├── pom.xml
  • SpringBootRestApiApplication.java: The main class for your Spring Boot application.
  • application.properties: Configuration file for the application.
  • pom.xml: Maven’s configuration file to manage dependencies.

Step 4: Create a Simple REST API

  1. Create a Controller:

    • Inside the com.example.springbootrestapi package, right-click and select New > Java Class.
    • Name the class HelloController.
  2. Add REST API Code:

    • Open HelloController.java and paste the following code:
      package com.example.springbootrestapi;
      
      import org.springframework.web.bind.annotation.GetMapping;
      import org.springframework.web.bind.annotation.RestController;
      
      @RestController
      public class HelloController {
      
          @GetMapping("/")
          public String sayHello() {
              return "Welcome to Spring Boot 3!";
          }
      }

Step 5: Run the Application

  1. Run the Application:

    • Open the SpringBootRestApiApplication.java file.
    • Right-click and select Run 'SpringBootRestApiApplication'.
  2. Verify the API:

    • Once the application starts, open your browser and go to:
      http://localhost:8080/
      
    • You should see the message:
      Welcome to Spring Boot 3!

Conclusion

You’ve successfully created a Spring Boot project, imported it into IntelliJ IDEA, and built a REST API. This basic setup can now be expanded to include more features, such as additional endpoints, services, or database connections. Happy coding!

My Top and Bestseller Udemy Courses. The sale is going on with a 70 - 80% discount. The discount coupon has been added to each course below:

Comments

Spring Boot 3 Paid Course Published for Free
on my Java Guides YouTube Channel

Subscribe to my YouTube Channel (165K+ subscribers):
Java Guides Channel

Top 10 My Udemy Courses with Huge Discount:
Udemy Courses - Ramesh Fadatare