by @kodeazy

How to create,build and run the SpringBoot application using command prompt?

Home » java » How to create,build and run the SpringBoot application using command prompt?

In this blog we will discuss on how to create,build and run springboot application with out using any IDE.


Java 1.8+ Maven 3.5+

Below are the steps to follow

  • Creating the pom.xml file and adding the classpath dependencies inside pom.xml file.
  • Writing the required code part.
  • Running the Example code.

Creating the pom.xml file

  • A Maven pom.xml file is used to build the project.
  • Here we create a pom.xml file and add the required dependencies.
  • Below is an example pom.xml file having spring-boot-starter-web dependency.

    <?xml version="1.0" encoding="UTF-8"?>
    <project xmlns="" xmlns:xsi=""

    Writing the required code part

  • To complete our application we need to create a Java file.
  • Maven compiles sources from src/main/java.
  • so add the below java code inside src/main/java path.

    import org.springframework.boot.SpringApplication;
    import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
    import org.springframework.web.bind.annotation.RequestMapping;
    import org.springframework.web.bind.annotation.RestController;
    class MyApplication{
    String example(){
    	return "My First SpringBoot Application";
    public static void main(String args[]){,args);

    In the above code we have three annotations.

  • @RestController
  • @EnableAutoConfiguration
  • @RequestMapping

@RestController It is used to handle the web requests. @EnableAutoConfiguration Configures the application based on the jar dependencies
@RequestMappingEnsures HTTP request with / path should be mapped to example() method.

Running the Example code. Now go back to the path where pom.xml file is present and execute the below command in command prompt.

mvn spring-boot:run

Spring Boot Running Example

Now open http://localhost:8080/

Spring Boot Running Example Output