Base de connaissances

SpringBoot Print

  • 0

How to Install Spring Boot CLI on Ubuntu 24.04 Using SDKMAN

This beginner-friendly guide explains how to manually install the Spring Boot CLI on an Ubuntu 24.04 server using SDKMAN.

The commands in this article follow the same installation process used by the supplied Spring Boot Ansible playbook.

What will be installed:
  • OpenJDK 17
  • SDKMAN
  • Spring Boot CLI
  • Git
  • curl
  • zip
  • unzip
Requirements:
  • Ubuntu 24.04 LTS
  • Root or sudo access
  • Internet connection
  • SSH access if using a remote server

Step 1: Connect to Your Ubuntu Server

If you are installing Spring Boot on a remote Ubuntu server, connect to it using SSH.

ssh username@SERVER-IP

Replace username with your Ubuntu username and SERVER-IP with the IP address of your server.

Example:

ssh ubuntu@203.0.113.10

If you are already logged into the Ubuntu terminal, continue to the next step.


Step 2: Check the Ubuntu Version

Check the operating system version:

lsb_release -a

The server should show Ubuntu 24.04 information.


Step 3: Update the Ubuntu Package List

The Ansible playbook first updates the package cache. Run:

sudo apt update

Upgrade installed packages:

sudo apt upgrade -y

Step 4: Install Required Packages

The Spring Boot Ansible playbook installs the following packages:

  • curl
  • zip
  • unzip
  • git
  • OpenJDK 17

Install them with:

sudo apt install -y curl zip unzip git openjdk-17-jdk

Wait until the installation finishes.


Step 5: Verify Java Installation

Spring Boot requires Java. The supplied Ansible playbook installs OpenJDK 17. Check the installed Java version:

java -version

The output should show Java 17.

You can also check the Java compiler:

javac -version

Step 6: Install SDKMAN

SDKMAN is used by the supplied Ansible playbook to install Spring Boot CLI.

Run the SDKMAN installation command:

curl -s https://get.sdkman.io | bash

The SDKMAN installer will download and configure SDKMAN in your home directory.

Important:

SDKMAN is installed for the current Linux user. Do not use sudo when installing SDKMAN itself.


Step 7: Load SDKMAN

After installing SDKMAN, load it into the current terminal session:

source "$HOME/.sdkman/bin/sdkman-init.sh"

You can verify that SDKMAN is available:

sdk version

If SDKMAN is working, it will display its version information.


Step 8: Install Spring Boot CLI Using SDKMAN

Install Spring Boot CLI using SDKMAN:

sdk install springboot

SDKMAN will download and install the Spring Boot CLI.

If SDKMAN asks whether you want to make the installed version the default, accept the default option.


Step 9: Verify Spring Boot CLI

Run:

spring --version

The command should display information about the installed Spring Boot CLI.

You can also run:

sdk current springboot

This shows the Spring Boot version currently selected by SDKMAN.

Installation check:

If spring --version successfully displays the Spring Boot CLI version, the Spring Boot CLI installation has completed successfully.


Step 10: Check the SDKMAN Installation Directory

SDKMAN is installed inside the current user's home directory. Check the directory:

ls -lah ~/.sdkman

The directory should contain SDKMAN files and directories.


Step 11: Check Spring Boot CLI Location

Find where the spring command is located:

which spring

You can also check the command:

type spring

Step 12: Check Git

Git is installed by the supplied Ansible playbook. Verify it:

git --version

Step 13: Check curl

Verify curl:

curl --version

Step 14: Check zip and unzip

Verify zip:

zip -v

Verify unzip:

unzip -v

Step 15: Test Spring Boot CLI

Run the Spring Boot CLI help command:

spring --help

If the help information appears, the Spring Boot CLI is available from the terminal.


Step 16: Check All Installed Components

Run the following commands to perform a final verification:

java -version

javac -version

git --version

curl --version

zip -v

unzip -v

sdk version

spring --version

Step 17: Using Spring Boot CLI

After the installation is complete, the spring command can be used from the terminal.

For example, display the Spring Boot CLI version:

spring --version

Display the available Spring Boot CLI commands:

spring --help

Step 18: If the "spring" Command Is Not Found

If you receive an error such as:

spring: command not found

reload SDKMAN:

source "$HOME/.sdkman/bin/sdkman-init.sh"

Then try:

spring --version

Step 19: If SDKMAN Is Not Available

If the sdk command is not available, load SDKMAN again:

source "$HOME/.sdkman/bin/sdkman-init.sh"

Check SDKMAN:

sdk version

Step 20: Check the Installed Spring Boot Version

Use SDKMAN to display the current Spring Boot version:

sdk current springboot

You can also use:

spring --version

Step 21: Useful SDKMAN Commands

List Spring Boot versions available through SDKMAN:

sdk list springboot

Display the current Spring Boot version:

sdk current springboot

Display SDKMAN information:

sdk version

Step 22: Restarting the Terminal

After installation, you can close and reopen your terminal. When you open a new terminal, SDKMAN normally loads automatically.

Test it:

sdk version

Then verify Spring Boot:

spring --version

Step 23: Final Installation Verification

Run the following commands:

echo "===== Java ====="
java -version

echo "===== Git ====="
git --version

echo "===== SDKMAN ====="
sdk version

echo "===== Spring Boot ====="
spring --version

echo "===== Spring Boot Location ====="
which spring

If each command returns information without an error, the main components from the Ansible playbook are installed.


Installation Complete

Congratulations!

Spring Boot CLI has been installed on Ubuntu 24.04 using SDKMAN.

  • OpenJDK 17 is installed.
  • SDKMAN is installed.
  • Spring Boot CLI is installed.
  • Git is installed.
  • curl is installed.
  • zip is installed.
  • unzip is installed.

The main verification command is:

spring --version

Installation Summary

Component Configuration
Operating System Ubuntu 24.04 LTS
Java OpenJDK 17
Spring Boot Installed through SDKMAN
SDK Manager SDKMAN
SDKMAN Directory ~/.sdkman
Git Installed
curl Installed
zip Installed
unzip Installed

Quick Verification Commands

Check Java:

java -version

Check SDKMAN:

sdk version

Check Spring Boot:

spring --version

Find Spring Boot:

which spring
Note:

The supplied Ansible playbook installs the Spring Boot CLI through SDKMAN, but it does not deploy a Spring Boot application, create a project, configure a web server, or expose a Spring Boot application through a public HTTP port. Therefore, this guide ends after verifying that the Spring Boot CLI is installed.

This knowledgebase article follows the supplied Spring Boot Ansible project, including Ubuntu package installation, OpenJDK 17, SDKMAN, Spring Boot CLI, Git, curl, zip, and unzip.


Cette réponse était-elle pertinente?
Back