You are currently viewing Creating a Spring Boot Project with Gradle

Creating a Spring Boot Project with Gradle

  • Post author:
  • Post category:Gradle
  • Post comments:0 Comments
  • Post last modified:January 27, 2024


  1. Java Development Kit (JDK) installed (version 8 or later)
  2. Gradle installed (version 4.0 or later)
  3. Integrated Development Environment (IDE) – Optional, but recommended (e.g., IntelliJ IDEA, Eclipse)

Step 1: Create a new Spring Boot project

You can use the Spring Initializr to generate a basic Spring Boot project with Gradle. Visit, select your project details, and choose ‘Gradle’ as the build tool. Download the generated project zip file and extract it to your preferred location.

Step 2: Import the project into your IDE

If you are using an IDE, import the project. In IntelliJ IDEA, you can do this by selecting File -> Open and choosing the project folder.

Step 3: Project Structure

The generated project structure should look something like this:

|-- src
|   |-- main
|       |-- java
|       |   `-- com
|       |       `-- example
|       |           `--
|       `-- resources
|           `--
|-- build.gradle
`-- settings.gradle

Step 4: Build.gradle Configuration

Open the build.gradle file in your project and add dependencies. For a basic Spring Boot application, you can add the following:

This configuration includes the Spring Boot Starter Web dependency for building a web application.

Step 5: Create a Simple Controller

Open the file in the com.example package and create a simple controller:

Step 6: Run the Application

Run your Spring Boot application using Gradle. Open a terminal and navigate to your project directory, then run:

./gradlew bootRun

Or on Windows:

gradlew bootRun

Visit http://localhost:8080/api/hello in your web browser to see the greeting message.

Congratulations! You’ve created a simple Spring Boot application using Gradle. You can now expand on this foundation by adding more controllers, services, and features to meet your application requirements.

Leave a Reply