Sunday, April 16, 2017
This section provides a quick introduction on how to develop a simple micro service which exposes a REST API using Spring Boot.

The intent is to do a simple “/sayhello” API which returns “Hello” as the output.

  • Open the Spring Tool Suite (STS) and click on Spring Starter Project.
Create a Spring Starter Project

  • Fill in the application details. For this example we would use Java 8 and Maven as the build system.
Spring Starter Project application details

  • Since we are exposing APIs from this application enable Web Services under Web. Refer the snapshot below.
Spring Starter Project Enable Web Services
  • Finish the application wizard and you would see the Spring project created and ready for use in Spring Tool Suite IDE. Under Maven dependencies all the dependent jars are already loaded. Also notice that pom.xml is created.
Spring Starter Project Application

  • Now let us understand the top level class.
package com.sourcetricks;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

public class MyFirstAppApplication {

   public static void main(String[] args) {, args);

@SpringBootApplication is a convenience annotation. The @SpringBootApplication annotation is equivalent to using @Configuration, @EnableAutoConfiguration and @ComponentScan with their default attributes if you are familiar with Spring annotations.

Otherwise we have one line of code in main program which launches the application.

  • Now let us introduce a new class HelloController which exposes the /sayhello API. This is achieved using @RestController and @RequestMapping annotations as shown below.

package com.sourcetricks;

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

public class HelloController {

    public String hello() {
      return "Hello";

  • Now we can run the project as a Java application in the STS IDE and we should start to see the embedded tomcat coming up on port 8080.

2017-04-16 07:27:43.657  INFO 17584 --- [           main] o.s.j.e.a.AnnotationMBeanExporter        : Registering beans for JMX exposure on startup
2017-04-16 07:27:43.790  INFO 17584 --- [           main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat started on port(s): 8080 (http)
2017-04-16 07:27:43.799  INFO 17584 --- [           main] com.sourcetricks.MyFirstAppApplication   : Started MyFirstAppApplication in 7.816 seconds (JVM running for 10.038)

  • Open a browser and invoke the /sayhello API we introduced.
Spring Boot Application - Launch Web Service
  • Next step is to package this application into a standalone application using Maven. If you notice the generated pom.xml file you will see the necessary build plugins already added since we selected Maven as the build system during project creation.
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="" xmlns:xsi=""


 <description>This is my first Spring Boot Web Service</description>

  <!-- lookup parent from repository -->





  • Go to the workspace folder where the application is stored in your workspace and run “mvn package” command. This builds and packages the application. You should see “MyFirstApp-0.0.1-SNAPSHOT.jar” bundled with all dependencies.
Maven standalone application package

  • You can test if the application starts up by running the command “java –jar MyFirstApp-0.0.1-SNAPSHOT.jar”. The same browser test can be done on the exposed API.

Now we are ready with a simple micro service based on Spring Boot. 


  1. Thank you for taking the time to provide us with your valuable information. We strive to provide our candidates with excellent care and we take your comments to heart.As always, we appreciate your confidence and trust in us
    Analytics Training In Chennai

  2. I want more and more articles and blogs please post soon such informative information.
    this guy makes good reviews

  3. Today’s GPS watches have all the sport-specific features to track every stride on the roads, but they’re also jammed with other sensors and technology—pairing with your smartphone—to keep you connected the rest of the day, too. Here are some of the top-of-the-line watches runners will want to check out Top GPS Watches

  4. It's interesting that many of the bloggers to helped clarify a few things for me as well as giving.Most of the ideas can be nice content.The people to give them a good shake to get your point and across the command.

    AWS Training in HRBR Layout
    AWS Training in Kalyan Nagar
    Best AWS Training Institute in Kalyan Nagar Bangalore

  5. Some us know all relating to the compelling medium you present powerful steps on this.Advanced Selenium Training in Chennai

  6. Thanks a lot very much for the high your blog post quality and results-oriented help. I won’t think twice to endorse to anybody who wants and needs support about this area. Best Java Training Institute Chennai

  7. I simply wanted to thank you so much again. I am not sure the things that I might have gone through without the type of hints revealed by you regarding that situation.

    Best Hadoop Training Institute In chennai

  8. I believe there are many more pleasurable opportunities ahead for individuals that looked at your site.

    Best Hadoop Training Institute In chennai

  9. I have read your blog. Your information is really useful for beginner. informations provided here are unique and easy to understandThanks for this useful infromation.
    QTP Training in Chennai
    Java Training in Chennai
    Python Training in Chennai

  10. I hope you continue to have such quality articles to share with everyone! I believe a lot of people will be surprised to read this article hotmail sign in

  11. Great article, really very helpful content you made. Thank you, keep sharing.

    Internet Of Things Services | Austere Technologies

  12. Great post just what I was looking for.

  13. Your good knowledge and kindness in playing with all the pieces were very useful. I don’t know what I would have done if I had not encountered such a step like this.

  14. wow...nice blog, very helpful information. Thanks for sharing.

    Best Software Company | Austere Technologies


    Mobility Services | Austere Technologies

  16. Thanks a lot very much for the high your blog post quality and results-oriented help. I won’t think twice to endorse to anybody who wants and needs support about this area.
    rpa training in chennai

  17. Appreciation for really being thoughtful and also for deciding on certain marvelous guides most people really want to be aware of.
    Best rpa training Institute in chennai

  18. I strongly believe that there will be great opportunities for those who looked into this area...
    Best Online Software Training Institute | DevOps Training

  19. Thanks a lot very much for the high your blog post quality and results-oriented help. I won’t think twice to endorse to anybody who wants and needs support about this area.
    datascience training in chennai


Contact Form


Email *

Message *

Back to Top