Access the full course here: javabrains.io/courses/spring_bootquickstart
Learn how to create a new REST endpoint by creating a brand new Spring MVC controller.
12 Comments on "Spring Boot Quick Start 11 – Adding a REST Controller"
For those whom it worked .. How did this work without adding @ComponentScan("io.javabrains")? At least, it didn't work until I added that 🙁
Hi Kaushik, Thanks for this wonderful tutorial. I can't see the tomcat running in my console. Can u help me ??
Try to create the "Application.properties" file in src/main/resources and add try to change you embedded tomcat server port by adding these lines into the Application.properties file: 1. logging.level.org.springframework: DEBUG2. server.port=8282Run again your project and try: localhost:8282/hello. Hope I helped!
thanks Rajesh for this tutorial
Thank you! Great videos!
Great work boss!!😀Instead of RequestMapping we can use @GetMapping and @PostMapping directly for the Get and Post request respectively.+1 if anybody find it useful.
ty for this video its really helpful 🙂 Great thumbsUP 🙂
what's the JAX-RS Reference Implementation used in this tutorial ?
Thanks for posting nice tutorial.One thing is not coming out clearly from this video is how auto scanning of @RestController and other inner annotations are resolved. From my understanding, spring auto scan start from classes in package where @SpringBootConfiguration is defined and that include classes in sub-packages of @SpringBootConfiguration class. That is the reason why HelloController is written inside springbootstarter.hello sub package.
It's not correct that @RequestMapping only maps to GET when no RequestMethod is specified. Instead, it will map to all HTTP methods. You can try by running a DELETE against localhost:8080/topics/ and it will still give you the list of topics – which makes a kinda weird API. So I guess, best practice would be to always specify the RequestMethod.
Thanks for catching this! You are right. I'll add an annotation to the video with the correction.
Totally right. At this point I used this kind of annotation for the GET Method instead@RequestMapping(value="/hello", method = RequestMethod.GET)
In CodeChannels.com, you can learn to code by watching videos and stay up to date with latest code shows, events and tutorials aggregated from various leading developer communities.
Copyright 2016 By CodeChannels.com All rights reserved.