Photo by Gabriel Heinzer / Unsplash

Generating Spring Boot Skeleton Project via Spring Boot CLI

Spring Boot Sep 12, 2018

Using the Spring Boot CLI to Generate Spring Boot Skeleton Project.

Introduction

Spring Boot CLI is a command line tool that you can use if you want to quickly develop a Spring application. It lets you run Groovy scripts, which means that you have a familiar Java-like syntax without so much boilerplate code. You can also bootstrap a new project or write your own command for it.

Command Language Interpreter (CLI), also known as command-line user interface, console user interface and character user interface (CUI), is a means of interacting with a computer program where the user (or client) issues commands to the program in the form of successive lines of text (command lines). A program which handles the interface is called a command language interpreter or shell (computing)

Goals

  1. Download & Install Spring Boot CLI
  2. Using the CLI to Generate Spring Boot Skeleton Project

Minimum Requirements

Step 1 - Download & Install Spring Boot CLI

  • Spring Boot CLI Download Link

  • Installation Steps

    • Set SPRING_HOME to point to the Spring CLI folder
    • Add SPRING_HOME/bin to your PATH environment variable
    • To test if you have successfully installed the CLI you can run either of the following commands:
      • spring --version or spring version
  • No specific environment variables are required to run the CLI

Step 2 - Using the CLI to Generate Spring Boot Skeleton Project

  • spring
    A help screen is displayed.

  • spring help
    Get more details about any of the supported commands.

  • spring init --dependencies=web,data-jpa my-example-project
    Create a new maven based spring boot project, my-example-project with spring-boot-starter-web and spring-boot-starter-data-jpa dependencies.

  • spring init --list
    List all the capabilities of Spring Starter.

  • spring init --build=maven --java-version=1.8 --dependencies=web,data-jpa --packaging=jar my-example-project.zip
    Create a maven project that uses Java 8 and jar packaging.

  • spring shell
    Command to launch an integrated shell on a Windows machine. From inside the embedded shell, you can run other commands directly. $ version

Running the Jar

  • Java -jar Application-Jar-Name.Jar
    Running the Spring Boot Application Jar

  • Java -jar -Dserver.port=9090 Application-Jar-Name.Jar
    Running Multiple Instances of Spring Boot Project on Different Ports

Other Commands

  • jcmd
    lists all running Java processes

  • Taskkill /PID PROCESS_ID_OF_RUNNING_APP /F
    replace the PROCESS_ID_OF_RUNNING_APP with the actual process id of the running jar found out from executing the previous command to shutdown the running jar.

  • jps -lv
    displays information about running java processes

  • echo %JAVA_HOME%
    prints environment variable JAVA_HOME

Tags

Anantha Raju C

| Poetry | Music | Cinema | Books | Visual Art | Software Engineering |