Skip to content
Spring Boot

Spring

Spring Boot

Spring

Spring Boot CLI

admin, March 21, 2025

Spring Boot CLI (Command Line Interface) is a tool that allows you to quickly develop Spring applications using Groovy scripts without requiring a full Java project setup. It simplifies prototyping and testing.

Installing Spring Boot CLI

You can install Spring Boot CLI via:

  • SDKMAN! (Recommended): shCopyEditsdk install springboot
  • Homebrew (macOS): shCopyEditbrew install spring-boot-cli
  • Manual Download:
    Download from Spring Boot’s official site.

Most Used Spring Boot CLI Commands

1. Check Version

spring --version

Displays the installed Spring Boot version.

2. Run a Groovy Script

spring run app.groovy

Executes a Spring Boot application written in Groovy.

3. Initialize a New Spring Boot Project

spring init --name=myapp --dependencies=web,data-jpa myapp

Creates a new Spring Boot project with specified dependencies.

4. List Available Starters (Dependencies)

spring init --list

Shows all available Spring Boot dependencies.

5. Start a Spring Boot Application

mvn spring-boot:run

or
gradle bootRun

Runs the application using Maven or Gradle.

6. Run Spring Shell

spring shell

Starts an interactive Spring shell for running Spring Boot CLI commands.

7. Package and Build the Application

mvn package

or
gradle build

Builds the application into a JAR file.

8. Run the Built JAR File

shCopyEditjava -jar target/myapp-0.0.1-SNAPSHOT.jar

Executes the compiled Spring Boot application.

9. Test the Application

shCopyEditmvn test

Runs unit tests.

10. Generate Application Properties

spring init --build=gradle --dependencies=web,thymeleaf --package-name=com.example demo-app
Spring Boot

Post navigation

Previous post
Next post

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

©2025 Spring Boot | WordPress Theme by SuperbThemes