SpringBoot启动器目录问题导致无法访问报错404

入门学习SpringBoot时遇到了一个问题,纠结了好长时间

源码资源:

       https://spring.io/guides/gs/rest-service/

 

访问i地址:http://localhost:8080/greeting

报错:

Whitelabel Error Page

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

Mon Dec 17 10:52:32 CST 2018

There was an unexpected error (type=Not Found, status=404).

No message available

 

解决问题的方法:

修改前:

SpringBoot启动器目录问题导致无法访问报错404_第1张图片

 

修改后:

SpringBoot启动器目录问题导致无法访问报错404_第2张图片

 

访问成功:

SpringBoot启动器目录问题导致无法访问报错404_第3张图片

   将启动器 Application 转移到 controller目录 就可以了

         应该是 启动器放在所有包外层,要不就是controller 同级别

你可能感兴趣的:(SPRINGBOOT)