Run Spring Boot Application Command Line Maven

Hey guys in this article, you will learn how to run Spring Boot application from command line using Maven.

Read More:


When we create a new spring boot project, spring initializer adds maven plugin to the pom.xml


We can use this plugin to package and generate the executable jar. It also generates maven wrapper files mvnw.cmd and

Create spring boot project

There are many different ways to create a spring boot application, you can follow the below articles to create one –

>> Create spring boot application using Spring initializer
>> Create spring boot application in Spring tool suite [STS]
>> Create spring boot application in IntelliJ IDEA

Add maven Dependencies

Open pom.xml and add the following dependencies –

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="" xmlns:xsi=""
		<relativePath/> <!-- lookup parent from repository -->
	<description>Spring boot app</description>




Create a Rest Controller

Create inside in.bushansirgur.springbootapp.controller package and add the following content

package in.bushansirgur.springbootapp.controller;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

public class HomeController {
	public String home() {
		return "This is home page";

Run the app from Command line

Go to the root of the project from command line, enter the following command to package the app


This will generate the Jar or war file inside the target folder depending upon the selection you made while creating the project.

mvnw is a maven wrapper files, spring initializer created these files to run the maven project. We don’t need to install Maven separately on our system.

To run the spring boot project from command line using maven, enter the following command from the root of the folder.


This will start the tomcat server on the default port 8080. Open the browser and navigate to the url http://localhost:8080/home

That’s it for this post, if you like this post, share this with your friends and colleagues or you can share this within your social media platform. Thanks, I will see you in our next post.

About the author

Bushan Sirgur

Hey guys, I am Bushan Sirgur from Banglore, India. Currently, I am working as an Associate project in an IT company.

View all posts

Leave a Reply

Your email address will not be published. Required fields are marked *