Tuesday, 12 November 2013

Spring Boot Hello world Example


Spring  Boot API provides easy way of creating stand alone applications with minimum effort and very less configurations. It contains embedded tomcat or jetty to run web applications. Using this API no need to worry about creating war and other configuration. See more about Spring boot

Here is one simple web application which is using Spring boot to print hello world to the user.

1. Create a Maven Project and add below dependencies

			<name>Spring Snapshots</name>
			<name>Spring Milestones</name>

2. Create a Controller class (

This is a controller class which is handling requests, here we are adding @EnableAutoConfiguration to take up auto configuration and in the main method using to create instance of the controller class.

package com.pretech;
import org.springframework.boot.*;
import org.springframework.boot.autoconfigure.*;
import org.springframework.stereotype.*;
import org.springframework.web.bind.annotation.*;
public class HelloWorldController {
    @RequestMapping(method = RequestMethod.GET)
      String welcome(String name) {
        return "Hello World Mr "+name;
    public static void main(String[] args) throws Exception {, args);

3. Run it

Run the above main program, your web application started via spring boot. Let us test this with below url