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 ...
随机推荐
- C#获取文件夹及文件的大小与占用空间的方法
本文详细介绍了利用C#实现根据路径,计算这个路径所占用的磁盘空间的方法 . 网上有很多资料都是获取文件夹/文件的大小的.对于占用空间的很少有完整的代码.这里介绍实现这一功能的完整代码,供大家参考一下. ...
- 关于Maven项目build时出现No compiler is provided in this environment的处理(转)
本文转自https://blog.csdn.net/lslk9898/article/details/73836745 近日有同事遇到在编译Maven项目时出现[ERROR] No compiler ...
- 在Android工程中加入AIDL文件时,gen目录生成的文件报错-问题解决
from://http://blog.csdn.net/watt520/article/details/10099047 今天在弄清除缓存的东东,按照网上别人的方法,创建了一个AIDL文件,这个时候发 ...
- uva 10406 Cutting tabletops
Problem D: Cutting tabletops Bever Lumber hires beavers to cut wood. The company has recently receiv ...
- VisualStudio: Vistual Studio XML 智能提示(转载)
原文地址:http://blog.csdn.net/hispring/article/details/5332312. 开发中经常遇到要和各种各样的 XML 打交道,编辑 XML 文件时最头痛的便是要 ...
- VisualStudio:如何监控 ADO.NET?
背景 很多场景下我们都需要监控 ADO.NET,如:查看某些框架(ORM)生成的 SQL.如何在不能使用 SQL Profile 的情况下监控 SQL 呢?VS 为我们提供了一个工具,本文做一些介绍! ...
- 破产姐妹第一季/全集2 Broke Girls迅雷下载
本季2 Broke Girls Season 1 (2011)看点:黑发泼辣的Max(凯特·戴琳斯 Kat Dennings 饰)在纽约布鲁克林区一家低档餐馆打工,餐馆同事包括小个子亚裔老板Han L ...
- 【转】Android思维导图
转自:http://www.open-open.com/lib/view/open1421201191375.html
- ViewHolder的标准写法
最标准的写法,就是为每一个AdapterView的子View新建一个对应的ViewHolder,同时声明为prtivate final static.ViewHolder类中定义各种成员变量. pub ...
- warning: LF will be replaced by CRLF in dubbo-demo-api/pom.xml.
今天使用git add .的时候出现了一个错误. 错误如下: 解决方案: $ rm -rf .git // 删除.git $ git config --global core.autocrlf fal ...