Building your First Spring boot application

Building your First Spring boot application 

To create a simple spring boot application :
http://start.spring.io/
Add the dependencies needed and then download the zip project to get started.

Follow steps in  the below link to get starte:
https://docs.spring.io/spring-boot/docs/current/reference/html/getting-started-first-application.html

Useful Links :
Understanding the spring annotations better.
https://stackoverflow.com/questions/6827752/whats-the-difference-between-component-repository-service-annotations-in


Building REST API's in Spring 

Annotate the main method with SpringBootSampleApplication : main method with the following annotation

@ComponentScan("path of the package")

Below is a sample controller which will return hello world string 
http://localhost:8080/sample/


@Controller
@EnableAutoConfiguration
@RequestMapping("/sample")
public class SampleController {
    @RequestMapping("/")
    @ResponseBody
    String home() {     
        return "Hello World!";  
    }
}
Run
 mvn spring-boot:run

Comments