zoukankan      html  css  js  c++  java
  • SpringBoot 出现Whitelabel Error Page 解决办法

    这是咋了,咋的就404了 我路径也挺对的啊 注解也都写上了啊 咋就找不到了呢? debug吧它不进方法 看日志吧,他还不报错 这家伙给我急的 百度一下午也没解决,最后还是看官网才知道错在了那里,程序只加载Application.java所在包及其子包下的内容。
    解决方案:
    一、在Application类中加上@ComponentScan(basePackages = {"com.demo.controller"}) 多个之间用","分隔 当然,这样治标不治本
    复制代码
     1 package com.demo.example.demo;
     2 
     3 import org.springframework.boot.SpringApplication;
     4 import org.springframework.boot.autoconfigure.SpringBootApplication;
     5 import org.springframework.context.annotation.ComponentScan;
     6 
     7 @SpringBootApplication
     8 @ComponentScan(basePackages = {"com.demo.controller"})
     9 public class Demo1Application {
    10 
    11     public static void main(String[] args) {
    12         SpringApplication.run(Demo1Application.class, args);
    13     }
    14 }
    复制代码
    二、把包的目录结构修改成正确的
    复制代码
     1 package com.demo;
     2 
     3 import org.springframework.boot.SpringApplication;
     4 import org.springframework.boot.autoconfigure.SpringBootApplication;
     5 import org.springframework.context.annotation.ComponentScan;
     6 
     7 @SpringBootApplication
     8 public class Demo1Application {
     9 
    10     public static void main(String[] args) {
    11         SpringApplication.run(Demo1Application.class, args);
    12     }
    13 }
    复制代码

     

  • 相关阅读:
    php获取OS信息
    坑爹的IE quirk模式
    [转]mysql privileges
    [转]VSFTPD的设置选项
    php性能分析工具xhprof
    php扩展安装
    又是万恶的IE....6
    ASP.NET操作文件(文件夹)简单生成html操作示例
    asp.net文件操作类
    c++/clr与c#的性能比较
  • 原文地址:https://www.cnblogs.com/zhangyongJava/p/8709029.html
Copyright © 2011-2022 走看看