SpringBoot报错 : Whitelabel Error Page
添加了一个Controller类,本来想试下Spring MVC是否可以正常运行,结果报错,Controller类的内容:
@RestController
public class Test1Controller { @RequestMapping("test1")
public String test1() {
return "hello";
} }
访问时报错信息是:

查了一下,发现扫描注解的路径仅限于程序Application.java所在包及其子包下的内容,我的项目结构:

我的启动程序位于com.example.demo,那么扫描路径只会扫描com.example.demo路径下的,我的controller类位于com.example.demo路径下,所以扫描不到,请求就访问不到了。
我把com.example.demo包的内容挪到com.example包下,重新启动,问题就解决了。
还有一种方法,就是手工设置扫描路径,修改DemoApplication.java的内容:
package com.example.demo; import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.ComponentScan; @SpringBootApplication
@ComponentScan(basePackages = {"com.example"})
public class DemoApplication { public static void main(String[] args) {
SpringApplication.run(DemoApplication.class, args);
}
}
红色文字部分是手工设置扫描路径的注解代码,如果有多个扫描路径,可以在多个扫描路径之间用","分隔
SpringBoot报错 : Whitelabel Error Page的更多相关文章
- springboot报错Whitelabel Error Page
第一次使用springboot没有问题.隔了两天继续看.一直报错Whitelabel Error Page. 重新搭建试了任何方法都错了. 报的就是一个404错误,犯了一个习惯性错误,一般都是loca ...
- 启动Springboot 报错 Whitelabel Error Page This application has no explicit mapping for /error, so you are seeing this as a fallback. Sat Jan 12 15:50:25 CST 2019 There was an unexpected error (type=Not
解决方案:http://www.cnblogs.com/michaelShao/p/6675186.html
- 新建SpringBoot项目运行页面报错Whitelabel Error Page This application has no explicit mapping for /error, so yo
新建SpringBoot项目运行页面报错Whitelabel Error Page This application has no explicit mapping for /error, so yo ...
- 初学 Spring boot 报错 Whitelabel Error Page 404
按照教程,写了个最简单的 HelloWorld,尼玛报错 -->Whitelabel Error Page 404. 网上99%都是项目结构不对,说什么 Application放在父级 pack ...
- 《Springboot极简教程》问题解决:Springboot启动报错 Whitelabel Error Page: This application has no explicit mapping for(转)
13.2 Spring Boot启动报错:Whitelabel Error Page 13.2 Spring Boot启动报错:Whitelabel Error Page 问题描述 Whitelabe ...
- SpringBoot入门报错 Whitelabel Error Page的总结
刚入门SpringBoot,编写helloControl类,去访问本地端口,无缘无故报了这个错误 Whitelabel Error Page 总结了下,目前我碰到的有三种会导致这种情况 1.当你的 S ...
- 关于Springboot启动报错 Whitelabel Error Page: This application has no explicit mapping
Whitelabel Error Page This application has no explicit mapping for /error, so you are seeing this as ...
- springboot项目出现Whitelabel Error Page的问题
springboot项目出现Whitelabel Error Page的问题 大概就是这种情况,然而昨天还是没问题的,通过对比就发现,是自己手欠了 简单来说解决办法就是将springboot的启动项目 ...
- SpringBoot报错:Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
Spring Boot报错:Error starting ApplicationContext. To display the conditions report re-run your applic ...
随机推荐
- Java嵌入式数据库H2学习总结(二)——在Web应用程序中使用H2数据库
一.搭建测试环境和项目 1.1.搭建JavaWeb测试项目 创建一个[H2DBTest]JavaWeb项目,找到H2数据库的jar文件,如下图所示: H2数据库就一个jar文件,这个Jar文件里面包含 ...
- 【Devops】【docker】【CI/CD】docker启动的Jenkins容器 - 系统管理 - 全局工具配置 - 自动安装JDK、Maven、Git、Docker
本篇适用于jenkins是启动的docker容器,自动安装JDK Maven Git Docker等全局工具 ========================================= ...
- ASP.NET MVC:mvc pattern
There are three pieces to the MVC pattern: The model—The domain that your software is built around. ...
- java高分局之jstat命令使用(转)
转自:http://blog.csdn.net/h_025/article/details/52813817 java高分局之jstat命令使用 jstat命令可以查看堆内存各部分的使用量,以及加载类 ...
- Linux下创建可执行bin安装文件
需求及应用场景 1.简化操作.一般的软件安装过程,如果想要精简步骤,我们一般会将需要在命令行中输入的命令写成一个脚本,同时将安装介质准备好.我们将脚本和安装介质上传到生产环境,然后通过执行脚本来完成安 ...
- Visual Studio 2013 智能提示功能消失解决办法
Visual Studio 2013中,智能提示功能突然用不了,查了一下,使用命令行重置VS的方法解决了这个问题.步骤如下: 开始菜单 -->所有程序-->Visual Studio 20 ...
- 前端框架amaze ui
支持jquery.react 支持web.移动端 http://t.amazeui.org/#/docs/getting-started?_k=syk56p http://dingtalk.amaze ...
- [Windows_Server_2012优化V1.1_20140425]
[Windows_Server_2012优化V1.1_20140425] Winsows Server 2012 Datacenter Evaluation Build 9200数据中心评估版GUI ...
- Sicily 1388. Quicksum
http://soj.me/1388 又一道字符串的水题.... #include <iostream> #include <cstring> using namespace ...
- 第三章 logstash - 输入插件之tcp与redis
常用的输入插件: tcp redis 一.tcp 1.用法 input { tcp { port => 4560 codec => json_lines mode => server ...