How to add multiple dependencies with the Spring CLI

How do you add multiple dependencies when creating a new project with the Spring CLI

In this tutorial, we are taking a look at a student’s question from my Spring Boot Introduction Course. This question has to do with the Spring CLI which is a great tool that allows you to quickly prototype with Spring. 

Spring CLI

Hi Dan,
I have created the spring boot application through spring CLI in the same way you showed in the video but my question is, How can we add multiple dependencies in our application through spring CLI? You have shown it for only one dependency i.e “web” using -d option but what if we want to add more dependencies through CLI?
In this article, I am going to talk through what the Spring CLI, how to install it and use it and of course answer the question above. 

Spring CLI

If you weren’t already aware there is a really cool tool called the Spring CLI (Command Line Interface). 

The Spring Boot CLI is a command line tool that can be used if you want to quickly prototype with Spring. It allows you to run Groovy scripts, which means that you have a familiar Java-like syntax, without so much boilerplate code. Did I mention I also teach a course on Groovy and absolutely love the language?  You don’t need to use the CLI to work with Spring Boot but it’s definitely the quickest way to get a Spring application off the ground.

Installing the Spring CLI

There are a couple of ways to install the Spring CLI and we will go through them here. First, you can install them manually by downloading the Spring CLI distribution from the Spring software repository:

Another way to install the Spring CLI is by using SDKMan. If you have been following me at all you know that I am a huge fan of SDKMan



When you have SDKMan installed you can install the Spring CLI by running the following command. 

Using the Spring CLI

Now that we have the Spring CLI installed its time to use it. If you aren’t sure what options are available you can run the help command to get more information. 

Spring CLI Help

In this first example, we will create and run a simple example. First, create a file called app.groovy that looks like this. 

Now you can run this application from the command line using the following command. 

Spring CLI run app

You can also use the Spring CLI to initialize a new project using This is similar to creating a new project in IntelliJ using the fancy wizard. So to answer our initial question which was how can we initialize a new project from the Spring CLI and add multiple dependencies: 

All you need to do is separate them using a comma and you can add as many dependencies as you like. 


I think the Spring CLI is a great little tool for getting started. I hope you found this tutorial useful and I hope you check out the Spring CLI if you haven’t already looked at it. 

Question: What other tools do you find are helpful for developers new to Spring Boot? 

Hi, I’m Dan Vega. I am a Software Engineer living just outside of one of my favorite places in the world, Cleveland, Ohio. I am a self-taught programmer who firmly believes that you can accomplish anything in this life if you put your mind to it, roll up your sleeves and are willing to put in the work.

I have been writing software for over 18+ years now and I use my knowledge, passion, and influence to help other developers achieve their goals. I teach online and currently, have over 30,000 students.

When I am not writing software, I have a number of things that really keep me busy. I love to read books, listen to podcasts and watch online courses. I have a real thirst for knowledge and it consumes me every single day of the week. I also love to run & lift heavy weights which keep me balanced throughout the week.

Please note: I reserve the right to delete comments that are offensive or off-topic.