spring-boot Installing the Spring Boot CLI

Help us to keep this website almost Ad Free! It takes only 10 seconds of your time:
> Step 1: Go view our video on YouTube: EF Core Bulk Extensions
> Step 2: And Like the video. BONUS: You can also share it!

Introduction

The Spring Boot CLI allows you to easily create and work with Spring Boot applications from the command-line.

Remarks

Once installed, the Spring Boot CLI can be run using the spring command:

To get command-line help:

$ spring help

To create and run your first Spring Boot Project:

$ spring init my-app
$ cd my-app
$ spring run my-app

Open your browser to localhost:8080:

$ open http://localhost:8080

You'll get the whitelabel error page because you haven't yet added any resources to your application, but you're all ready to go with just the following files:

my-app/
├── mvnw
├── mvnw.cmd
├── pom.xml
└── src/
    ├── main/
    │   ├── java/
    │   │   └── com/
    │   │       └── example/
    │   │           └── DemoApplication.java
    │   └── resources/
    │       └── application.properties
    └── test/
        └── java/
            └── com/
                └── example/
                    └── DemoApplicationTests.java
  • mvnw and mvnw.cmd - Maven wrapper scripts that will download and install Maven (if necessary) on the first use.
  • pom.xml - The Maven project definition
  • DemoApplication.java - the main class that launches your Spring Boot application.
  • application.properties - A file for externalized configuration properties. (Can also be given a .yml extension.)
  • DemoApplicationTests.java - A unit test that validates initialization of the Spring Boot application context.


Got any spring-boot Question?