Wednesday, April 6, 2022

Whitelabel Error Page

When I start my first spring boot application, I was very happy about after first Hello World program

just one hello method and return Hello world 


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

@RestController
public class HelloWorld {

@GetMapping(path = "/hello-world")
public String Hello(){
return "Hello World !!!";
}
}
and i run with this with 
http://localhost:8080/hello-world
Guess what !!!
got a big fat error page 

Whitelabel Error Page

This application has no explicit mapping for /error, so you are seeing this as a fallback.

Thu Apr 07 07:17:58 AEST 2022
There was an unexpected error (type=Not Found, status=404).
No message available

Solution for this funny message 

This is clearly not an error with my code. code or syntax are all correct.
the problem lies on my folder stucture

com
   +- APP
         +- Application.java  <--- your main class should be here, above your controller classes
         |
         +- model
         |   +- user.java
         +- controller
             +- UserController.java
my conroller package was out side the main package. 
more technical perspective 
it should be 

1 comment:

  1. https://stackoverflow.com/questions/31134333/this-application-has-no-explicit-mapping-for-error

    ReplyDelete

Feign Client Using Spring Boot | @EnableFeignClient | @FeignClient | FeignClient Spring Cloud

This is the video where I learnt Feign client, short and simple explanation. 1. Add dependency  <dependency> <groupId> ...