I am running spring-boot application in intellij and all of my scheduled tasks and everything is working fine but my controller which i have registered with @RestController and @RequestMapping are not getting registered. I am getting 404 when trying to access these while same is working fine when i am using eclipse. Even my ide console is showing rest controller as registered:
RequestMappingHandlerMapping - Mapped "{[/api/{v1}/restaurant/{cloudSiteId}/staff/{staffId}],methods=[GET]}" onto private java.lang.Object com.limetray.inventory.controller.StaffLocationController.getStaffDetail
Not able to guess what might go wrong ?
We went through the two most common reasons for receiving a 404 response from our Spring application. The first was using an incorrect URI while making the request. The second was mapping the DispatcherServlet to the wrong url-pattern in web. xml.
Class NoHandlerFoundException By default when the DispatcherServlet can't find a handler for a request it sends a 404 response. However if its property "throwExceptionIfNoHandlerFound" is set to true this exception is raised and may be handled with a configured HandlerExceptionResolver.
Another way of disabling the WhiteLabel Error is excluding the ErrorMvcAutoConfiguration . Alternatively, the exclusion can be done in an annotation. When the WhiteLabel Error Page is disabled and no custom error page is provided, the web server's error page (Tomcat, Jetty) is shown.
If your controller is in a separate package from your Main class you can try adding a component scan to your main class pointing to the package you have your controllers in. Example:
@ComponentScan({ "x.y.z.myPackage1", "x.y.z.myPackage2" })
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With