Bootstrap Spring Boot Application Project

What is Spring boot? Spring Boot makes it easy to create stand-alone, production-grade Spring based Applications that you can “just run”. We take an opinionated view of the Spring platform and third-party libraries so you can get started with minimum fuss. Most Spring Boot applications need very little Spring configuration. Detailed Explanation here

Let’s create our first spring boot application.


  1. Open terminal and fire:
  2. mvn archetype:generate DartifactId=spring-boot-starter DarchetypeArtifactId=mavenarchetypequickstart DinteractiveMode=false
  3. Once maven generates initial project structure. Open your favorite IDE. Mine is Intellij. And import the project as maven project.
  4. Let’s update pom.xml. Notice that we have a parent pom for our dependencies. It helps in simplifying our dependency management, as it automatically inherit dependencies in the parent. Next thing to notice that we spring starter project dependency without any version. Actually spring provides dozens of starter dependencies which is evolving every day. These dependency are bundled and tested for automatic configuration setup which means we have write less/No configuration files. Say no to XML please !!! No let’s do the last update to the POM. Add spring boot maven plugin to POM. This starts apache embedded tomcat container. It also creates a executable FAT jar. Our deadly POM for spring boot is created.
    <project xmlns="" xmlns:xsi=""
  5. Now time to update main class i.e First refactor and update to Next annotate Application class with @SpringBootApplication which is equivalent to @Configuration, @EnableAutoConfiguration and @ComponentScan. Finally update main method by throwing Exception from the main method. Then start springrunner class which takes main class and args which is passed from command line.
    import org.springframework.boot.SpringApplication;
    import org.springframework.boot.autoconfigure.SpringBootApplication;
    import org.springframework.web.bind.annotation.RequestMapping;
    import org.springframework.web.bind.annotation.RestController;
     * Starter!
    public class Application
        public static void main( String[] args )
  , args);
  6. Now let’s run our project, using springboot maven plugin. Go to project directory and run  mvn spring-boot:run This command will compile your project and run embedded tomcat server. Check the terminal, it will say our application waiting for Http request on port:8080 Let’s create a small service which we will consume.
    class Hello {
        public String sayHello() {
            return "You are good";

    Now instead of running mvn plugin to start the application, we will use the best practice. Run mvn clean package and wait to complete. Once it completes, check target folder for the executable jar. Now fire java -jar target/spring-boot-starter-1.0-SNAPSHOT.jar to run the application.nasruddin@nasruddin-studio-1555: ~-Project-spring-boot-tutorials_006

  7. Open console and hit http://localhost:8080/ to consume our service.localhost:8080 - Google Chrome_005

Source Code on GitHub


One thought on “Bootstrap Spring Boot Application Project

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s