Spring Boot Whitelabel Error page (type=Not Found, status=404)

前端 未结 5 2296
离开以前
离开以前 2021-02-19 10:31

Good afternoon! I\'m starting spring studies, I\'m following a tutorial the same way, but it returns an error:

Folder structure:

The strange th

5条回答
  •  忘掉有多难
    2021-02-19 11:04

    As a beginner to the SpringBoot, this error can be happened to anyone at least one time, because for a few reasons.

    1. The Application class (eg: SpringAppApplication.java) should be at the root level, as well as the controller classes can be placed under the same level or maybe in a subdirectory. This application class should be denoted using @SpringBootApplication or extends SpringBootApplication
    2. You may miss @RestController annotation at top of the controller class.
    3. Or can be missed the mapping annotation.( @PostMapping("/save") or @GetMapping("/id") etc.)
    4. finally just check whether you are entering the correct request mapping address(URL) you may miss a slash or @RequestMapping("/customer")(if the annotation available in your controller class) or spellings error in the URL.

提交回复
热议问题