EDUCBA

EDUCBA

MENUMENU
  • Free Tutorials
  • Free Courses
  • Certification Courses
  • 600+ Courses All in One Bundle
  • Login
Home Software Development Software Development Tutorials Spring Tutorial Spring Boot CLI
Secondary Sidebar
Spring Tutorial
  • Spring Boot
    • What is Spring Boot
    • Spring Boot flyway
    • Spring Boot framework
    • Spring Boot Logback
    • Spring Boot actuator endpoints
    • Spring Boot gRPC
    • Spring Boot jdbctemplate example
    • Spring Boot ehcache
    • Spring Boot Architecture
    • Spring Boot Port
    • Introduction of spring boot
    • Spring Boot ide
    • Spring Boot Netty
    • Spring Boot ORM
    • Spring Boot Versions
    • Spring Boot JUnit
    • Spring Boot Keycloak
    • Spring Boot gradle
    • Spring Boot Lombok
    • Spring Boot autowired
    • Spring Boot bean
    • Spring Boot hibernate
    • Spring Boot integration test
    • Spring Boot jdbc
    • Spring Boot MongoDB
    • Spring Boot postgresql
    • Spring Boot rest
    • Spring Boot swagger
    • Spring Boot thymeleaf
    • Spring Boot Unit Test
    • Spring Boot Webflux
    • Spring Boot webclient
    • Spring Boot kubernetes
    • Spring Boot Properties
    • Spring Boot Validation
    • Spring Boot Feature
    • Spring Boot Application
    • Spring Boot email
    • Spring Boot MVC
    • Spring Boot Exception Handling
    • Spring Boot Starter Parent
    • Spring Boot Docker
    • Spring Boot Logging
    • Spring Boot Query
    • Spring Boot Multiple Data Sources
    • Spring Boot Basic Authentication
    • Spring Boot Test
    • Spring Boot jwt
    • Spring Boot Liquibase
    • Spring Boot Prometheus
    • Spring Boot debug
    • Spring Boot GraalVM
    • Spring Boot Batch
    • Spring Boot controller
    • Spring Boot CLI
    • Spring Boot file upload
    • Spring Boot interceptor
    • Spring Boot Service
    • Spring Boot Configuration
    • Spring Boot Datasource Configuration
    • Spring Boot Annotations
    • Spring Boot Starter We
    • Spring Boot Actuator
    • Spring Boot DevTools
    • Spring Boot Repository
    • Spring Boot Dependencies
    • Spring Boot Path Variable
    • Spring Boot Microservices
    • Spring Boot Run Command
    • Spring Boot application.properties
    • Spring Boot Transaction Management
    • Spring Boot Banner
    • Spring Boot JPA
    • Spring Boot Change Port
    • Spring Boot RestTemplate
    • Spring Boot cors
    • Spring Boot HTTPS
    • Spring Boot OAuth2
    • Spring Boot Profiles
    • Spring Boot Interview Questions
    • Spring Boot filter
    • Spring boot logging level
    • Spring Boot Cache
    • Spring Boot Advantages
    • Spring Boot Scheduler
    • Spring Boot Initializr
    • Spring Boot Maven
    • Spring Boot Admin
    • Spring Boot Tomcat
    • Spring Boot WebSocket
    • Spring Boot Executable Jar
    • Spring Boot CommandLineRunner
    • Spring Boot DataSource
    • Spring Batch Scheduler
    • Spring Batch Example
    • Spring Batch Tasklet
    • Spring Batch Admin
    • Spring Batch
    • Spring Boot Qualifier
    • Spring Boot War
    • Spring Boot Test Configuration
  • Spring
    • What is Spring Framework?
    • Spring Architecture
    • What is Spring Integration?
    • IoC Containers
    • What is AOP?
    • Spring Modules
    • Spring Batch Processing
    • Spring Batch Partitioner
    • Spring Batch Job
    • Spring AOP
    • Spring Expression Language
    • Dependency Injection in Spring
    • Spring Batch Architecture
    • Spring framework Interview Questions
  • Spring Cloud Basics
    • What is Spring Cloud
    • Spring Cloud Contract
    • Spring Cloud Components
    • Spring Cloud Version
    • Spring Cloud Data Flow
    • Spring cloud stream
    • Spring Cloud Dependencies
    • Spring cloud microservices
    • spring cloud gateway
    • Spring Cloud Config
    • Spring Cloud Kubernetes
    • Spring Cloud Sleuth

Spring Boot CLI

Spring Boot CLI

Introduction to Spring Boot CLI

In Spring boot, we have spring boot CLI, which mainly stands for the command-line interface. This tool allows us to execute the same set of commands which helps us to speed up the project execution via the command line. In other frameworks also, they come up with a command-line by the use of it, we can easily create, run and add a required dependency to our project. It works in the same way. By the use of it, we can easily and fastly create the spring boot application, which makes the process even quicker for us. Also, this CLI can run the script written in groovy, which means developers need not worry about the boilerplate code, which only allows us to focus on writing the business logic for the application.

Installation and Setup for Spring Boot CLI

As of now, we already know that spring CLI is a command-line interface that requires some command to be executed on the command prompt to use it and make the application faster.

Start Your Free Software Development Course

Web development, programming languages, Software testing & others

We will first see how we can setup its environment on the machine and also some of its useful commands to use while developing.

1. The first step we need to do is we have to setup the spring boot CLI on our machine; for this, we need to first setup the JDK on our machine. We can download this from Oracle official website.

After downloading it, we have to setup the path for Java in our environment properties; for reference, follow the below path and replace it with yours.

Example:

set PATH= path_to_bin
set JAVA_HOME= path_to_jdk

2. Now, we can download the latest version of the spring boot command-line interface, i.e. CLI, from the below-mentioned link. Where you will find so many versions, choose the version you required and download the zip.

Spring Boot CLI 1

3. After downloading the zip extract, set the path in the environment variable as we set for JDK in the above step to use this globally.

4. After doing all this, we can just verify if the spring boot CLI is properly installed or not by using the below command.

Example:

spring –version

After executing this, you may have some logs printing the version for you.

Spring Boot CLI Commands with Examples

Here we will see some of the useful commands which we need to know before we start using them, this commands we can directly write on the CLI and perform the operations we want.

1. Spring –Version: If you want to know the version of the Spring boot CLI then just go to CLI and type in this command; after pressing enter, you will see the correct version of your CLI installed on your system. This command also can be used as the verification or to check the spring boot CLI is properly installed and working fine.

2. Now, we can run the application that we have created. For this, we can first go to the project folder that you have created and, on that path, open the command prompt. Else you can just open the command prompt and type in the path of your project.

Now to run your application, type in the below command.

Example:

spring run your_file_name;

As you can see, we have used the run command to run it. On the place of the file, the name provides your project file name like below and press enter.

Example:

spring run TradersApplication.groovy

Output:

Spring Boot CLI 2

3. Spring: This command will simply return the help screen for us. It does not take any argument with it. It can also be a checking command for spring boot CLI after installation.

4. Spring help run: This command will open more details about the commands we have available in the spring boot CLI, just write it in your command prompt and press enter.

5. We can also specify the port number for our application by using the spring boot CLI; run command this command takes the argument using ‘–‘ this operator.

Below you can find the reference for this command to change the port.

Syntax:

Spring run file_name -- --server.port= port_number

With the run command, we can use the server.port argument to specify the port for our application.

Syntax:

spring run demo.groovy -- --server.port=8081

6. We can also set the JAVA_OPTS variable from the spring boot CLI; we can find the below command.

Example:

JAVA_OPTS=-Xmx1024m spring run demo.groovy

7. If we want to run the test cases, we can use the below test command to run the test cases for us from the application.

Syntax:

spring test project_fiel_name test_file_aname

In this way, we can define the command.

Syntax:

spring test demo.groovy demotest.groovy

8. To create a new project using the spring boot CLI, we should use the below command;

Syntax:

spring init --dependencies=dep projectn_name

From the above line of code, we are able to now initialize the new project from scratch.

Syntax:

spring init --dependencies=web,data-jpa demo-project

Conclusion

By the use of this, we can easily and quickly build or spring boot applications. Just we need to remember a few of its important commands, we do this all things by using some editor, so after learning this, we can easily make all the things using the commands only which is very quick.

Recommended Articles

This is a guide to Spring Boot CLI. Here we discuss the introduction, installation, setup and spring boot CLI commands with examples. You may also have a look at the following articles to learn more –

  1. Maven Repository Spring
  2. Spring Boot DevTools
  3. Spring AOP
  4. Spring Cloud Components
Popular Course in this category
Spring Boot Training Program (2 Courses, 3 Project)
  2 Online Courses |  3 Hands-on Projects |  22+ Hours |  Verifiable Certificate of Completion
4.5
Price

View Course

Related Courses

Spring Framework Training (4 Courses, 6 Projects)4.9
All in One Data Science Bundle (360+ Courses, 50+ projects)4.8
Primary Sidebar
Footer
About Us
  • Blog
  • Who is EDUCBA?
  • Sign Up
  • Live Classes
  • Corporate Training
  • Certificate from Top Institutions
  • Contact Us
  • Verifiable Certificate
  • Reviews
  • Terms and Conditions
  • Privacy Policy
  •  
Apps
  • iPhone & iPad
  • Android
Resources
  • Free Courses
  • Java Tutorials
  • Python Tutorials
  • All Tutorials
Certification Courses
  • All Courses
  • Software Development Course - All in One Bundle
  • Become a Python Developer
  • Java Course
  • Become a Selenium Automation Tester
  • Become an IoT Developer
  • ASP.NET Course
  • VB.NET Course
  • PHP Course

ISO 10004:2018 & ISO 9001:2015 Certified

© 2023 - EDUCBA. ALL RIGHTS RESERVED. THE CERTIFICATION NAMES ARE THE TRADEMARKS OF THEIR RESPECTIVE OWNERS.

EDUCBA
Free Software Development Course

Web development, programming languages, Software testing & others

By continuing above step, you agree to our Terms of Use and Privacy Policy.
*Please provide your correct email id. Login details for this Free course will be emailed to you
EDUCBA

*Please provide your correct email id. Login details for this Free course will be emailed to you

Let’s Get Started

By signing up, you agree to our Terms of Use and Privacy Policy.

EDUCBA

*Please provide your correct email id. Login details for this Free course will be emailed to you
EDUCBA

*Please provide your correct email id. Login details for this Free course will be emailed to you
EDUCBA Login

Forgot Password?

By signing up, you agree to our Terms of Use and Privacy Policy.

This website or its third-party tools use cookies, which are necessary to its functioning and required to achieve the purposes illustrated in the cookie policy. By closing this banner, scrolling this page, clicking a link or continuing to browse otherwise, you agree to our Privacy Policy

Loading . . .
Quiz
Question:

Answer:

Quiz Result
Total QuestionsCorrect AnswersWrong AnswersPercentage

Explore 1000+ varieties of Mock tests View more