spring-boot-01 Whitelabel Error Page

版权声明:本文为博主原创文章,经博主允许,可自由共享,尽量不要用于商业用途。 https://blog.csdn.net/matrixbbs/article/details/88104964

初学,新建一个项目
工具:STS
new Spring Starter Project
Group:com.zfh.demo
Restful->web->finish
加入一个包controller
创建一个class,然后注解为一个控制器

@RestController
//@RequestMapping(value = "/index")
public class IndexController {

	@RequestMapping("/hello")
	public String index() {
		return "hello world";
	}
}

添加工具
然后直接跑

结果遇到如下出错提示
Whitelabel Error Page
This application has no explicit mapping for /error, so you are seeing this as a fallback.

Mon Mar 04 10:42:27 CST 2019
There was an unexpected error (type=Not Found, status=404).
No message available

出错的原因是因为找不到资源

调整项目目录层级
要求ExampleApplication.java在首层

最终解决问题
看到预期的结果

猜你喜欢

转载自blog.csdn.net/matrixbbs/article/details/88104964