Monday 9 July 2018

Working with Spring Boot CLI

Spring Boot CLI is a command line interface tool, by using this you can quickly create spring projects.

In this post, I am going to show you the setup and basics of spring boot CLI.

Setting up Spring Boot CLI
Download spring boot from below location. Depends on the spring boot version that you are using, url can change.

Extract the downloaded zip file, you can able to see below kind of structure.




You can go through the instructions in ‘INSTALL.txt’ file.

Spring cli executable is located at bin directory. We should add the path of spring bin directory to system path.

How to add spring cli bin path to system path? 
On Windows systems, follow below procedure. 
Step1: Right click computer icon, and open the properties window.


Step 2: Click on the Advanced system settings tab as shown below. Then it will open the system properties window.


Step3: Open the System properties and choose the Advanced tab. Click on the “Environment Variable” button.


Step 4
You will get a window like below. It contains 2 sections, one for user variables and other for System variables section.


Edit the path from system variables section, and add the spring bin path.

On Linux Systems
If spring cli is extracted to the location "/usr/krishna/spring-2.0.1.RELEASE/bin"

You have to update the path like below
export PATH=/usr/krishna/spring-2.0.1.RELEASE/bin:$PATH
                          OR
you can update the path variable in /etc/environment file for linux or .profile file in AIX like below
export PATH=/usr/krishna/spring-2.0.1.RELEASE/bin:$PATH

Testing the spring cli setup
Open command prompt (or) shell and execute the command ‘spring’.
C:\>spring
usage: spring [--help] [--version]
       <command> [<args>]

Available commands are:

  run [options] <files> [--] [args]
    Run a spring groovy script

  grab
    Download a spring groovy script's dependencies to ./repository

  jar [options] <jar-name> <files>
    Create a self-contained executable jar file from a Spring Groovy script

  war [options] <war-name> <files>
    Create a self-contained executable war file from a Spring Groovy script

  install [options] <coordinates>
    Install dependencies to the lib/ext directory

  uninstall [options] <coordinates>
    Uninstall dependencies from the lib/ext directory

  init [options] [location]
    Initialize a new project using Spring Initializr (start.spring.io)

  encodepassword [options] <password to encode>
    Encode a password for use with Spring Security

  shell
    Start a nested shell

Common options:

  -d, --debug Verbose mode
    Print additional status information for the command you are running


See 'spring help <command>' for more information on a specific command.

If you able to see above kind of output, then spring cli installation is successful.





Previous                                                 Next                                                 Home

No comments:

Post a Comment