Installing the Spring Boot CLI

Installing the Spring Boot CLI

The Spring Boot CLI (Command Line Interface) is a command line tool that you can use to quickly
prototype with Spring. It lets you run Groovy scripts, which means that you have a familiar Javalike
syntax without so much boilerplate code.

You do not need to use the CLI to work with Spring Boot, but it is definitely the quickest way to get a
Spring application off the ground.

Manual Installation
You can download the Spring CLI distribution from the Spring software repository:
• spring-boot-cli-2.3.0.M1-bin.zip
• spring-boot-cli-2.3.0.M1-bin.tar.gz
Cutting edge snapshot distributions are also available.

Once downloaded, follow the INSTALL.txt instructions from the unpacked archive. In summary,
there is a spring script (spring.bat for Windows) in a bin/ directory in the .zip file. Alternatively,
you can use java -jar with the .jar file (the script helps you to be sure that the classpath is set
correctly).

Installation with SDKMAN!

SDKMAN! (The Software Development Kit Manager) can be used for managing multiple versions of
various binary SDKs, including Groovy and the Spring Boot CLI. Get SDKMAN! from sdkman.io and install Spring Boot by using the following commands:
$ sdk install springboot
$ spring --version
Spring Boot v2.3.0.M1

If you develop features for the CLI and want easy access to the version you built, use the following
commands:
$ sdk install springboot dev /path/to/spring-boot/spring-boot-cli/target/spring-bootcli-
2.3.0.M1-bin/spring-2.3.0.M1/
$ sdk default springboot dev
$ spring --version
Spring CLI v2.3.0.M1

The preceding instructions install a local instance of spring called the dev instance. It points at your
target build location, so every time you rebuild Spring Boot, spring is up-to-date.
You can see it by running the following command:

$ sdk ls springboot
================================================================================
Available Springboot Versions
================================================================================
> + dev
* 2.3.0.M1
================================================================================
+ - local version
* - installed
> - currently in use
================================================================================

OSX Homebrew Installation

If you are on a Mac and use Homebrew, you can install the Spring Boot CLI by using the following
commands:

$ brew tap pivotal/tap
$ brew install springboot
Homebrew installs spring to /usr/local/bin.

If you do not see the formula, your installation of brew might be out-of-date. In
that case, run brew update and try again.

MacPorts Installation

If you are on a Mac and use MacPorts, you can install the Spring Boot CLI by using the following
command:
$ sudo port install spring-boot-cli

Command-line Completion

The Spring Boot CLI includes scripts that provide command completion for the BASH and zsh shells.
You can source the script (also named spring) in any shell or put it in your personal or system-wide
bash completion initialization. On a Debian system, the system-wide scripts are in /shellcompletion/
bash and all scripts in that directory are executed when a new shell starts. For example,
to run the script manually if you have installed by using SDKMAN!, use the following commands:

$ . ~/.sdkman/candidates/springboot/current/shell-completion/bash/spring
$ spring <HIT TAB HERE>
grab help jar run test version

Windows Scoop Installation

If you are on a Windows and use Scoop, you can install the Spring Boot CLI by using the following
commands:
> scoop bucket add extras
> scoop install springboot
Scoop installs spring to ~/scoop/apps/springboot/current/bin.

Quick-start Spring CLI Example

You can use the following web application to test your installation. To start, create a file called
app.groovy, as follows:
@RestController
class ThisWillActuallyRun {
@RequestMapping("/")
String home() {
"Hello World!"
}
}

Then run it from a shell, as follows:
$ spring run app.groovy

The first run of your application is slow, as dependencies are downloaded.
Subsequent runs are much quicker.
Open localhost:8080 in your favorite web browser. You should see the following output:



Comments

Popular posts from this blog

Today Walkin 14th-Sept

Hibernate Search - Elasticsearch with JSON manipulation

Spring Elasticsearch Operations