Whitelabel Error Page There was an unexpected error (type=Not Found, status=404)

Whitelabel Error Page There was an unexpected error (type=Not Found, status=404)
最近在做springboot项目的freemarker模板,当一切配置好运行时,什么都没有做呢,就先给我来了一个小惊喜。经过百度各种博客,发现普遍的3种情况:

第1种 Application启动类的位置不对.要将Application类放在最外侧,即包含所有子包,spring-boot会自动加载启动类所在包下及其子包下的所有组件

第2种 在springboot的配置文件:application.yml或application.properties中关于视图解析器的配置问题:

当pom文件下的spring-boot-starter-paren版本高时使用:spring.mvc.view.prefix/spring.mvc.view.suffix

第3种 控制器的URL路径书写问题:

@RequestMapping(“xxxxxxxxxxxxxx”) ,实际访问的路径与”xxx”不符合

综合以上几种,发现我的问题都不是。在创建完springboot工程后,发现我的static文件夹并没有添加index.html文件,这就很尴尬了,因为springboot默认运行的是static文件夹下的文件,所以如果你的情况和我类似可以试一下,如果你的是其他问题,下面有几种关于404的解决方式可以参考一下
Whitelabel Error Page There was an unexpected error (type=Not Found, status=404)

1 添加依赖
在pom.xml文件中添加一段依赖
<dependency》
<groupId》org.springframework.boot</groupId》
<artifactId》spring-boot-starter-thymeleaf</artifactId》
</dependency》
额 这里的依赖标签打出来之后就莫名的隐藏了,所以后边的是》不会隐藏,各位小伙伴注意一下哈,把》换成>就可以了

2 类名上面加一个@RestController
加上这个之后你的默认页面可能不会404,但是controller方法中返回的不再是html或jsp页面了,具体请参考https://www.cnblogs.com/shuaifing/p/8119664.html这个博客

如果有小伙伴碰到类似错误的,欢迎大家留言讨论