【问题标题】:Whitelabel error page on the first server hit- Spring Boot第一个服务器命中的 Whitelabel 错误页面 - Spring Boot
【发布时间】:2020-03-03 09:35:21
【问题描述】:

我正在按照基本的 Spring Boot 应用程序步骤来设置基本的 Spring Boot 应用程序。已根据需要创建 REST 控制器。但是,在运行应用程序后,我在 localhost:8080-“Whitelabel 错误页面”上收到此文本

此应用程序没有 /error 的显式映射, 所以你认为这是一个后备。

2019 年 11 月 7 日星期四 01:41:42 IST 出现意外错误(类型=未找到,状态=404)。 没有可用的消息“

尝试在“/”映射之外添加另一个回调方法,但它给出了相同的错误。

控制器代码:

    @RestController
        public class TestController {
        @RequestMapping(value = "/")
         public String home() {
          return "Spring boot is working!";
         }

         @RequestMapping("/testing")
         public String testing() {
          return "Spring boot is working!";
         }

【问题讨论】:

    标签: spring-boot


    【解决方案1】:

    如果您的应用程序类使用 @SpringBootApplication 注释在根目录中并且其他是它的子包,则不需要显式 @ComponentScan。

    【讨论】:

      【解决方案2】:

      尝试在您的主类中添加低于类级别的注释: @ComponentScan(basePackages = {(你的控制器包的名称)}

      【讨论】:

        猜你喜欢
        • 2017-06-03
        • 1970-01-01
        • 1970-01-01
        • 2021-12-20
        • 2018-06-09
        • 1970-01-01
        • 1970-01-01
        • 2021-09-24
        • 2014-10-10
        相关资源
        最近更新 更多