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-worldGuess 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 2022There 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
https://stackoverflow.com/questions/31134333/this-application-has-no-explicit-mapping-for-error
ReplyDelete