1.先看看是不是Application 启动类 的位置不对:
如图所示:
启动项一定要在最外层;
2.按照博主方法(我没碰到)
:
【浏览器的 url 与注解 @GetMapping("/xxxx")不匹配】请注意:spring-boot 默认访问页面的目录是 templates
3.(我自己的问题):在pom.xml文件里配置thymeleaf引擎依赖
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
具体加的位置如图所示;
需要注意的是,刚添加的时候,maven包可能没有更新,所以系统会提示把报错。
右上角这里会是红×号,然后打开以后 点击刷新按钮,重新导包就可以了。
最后:
输入localhost:8080 就成功了
最后附上学习的两篇博主文章:(文章是根据他们结合学习来写的)
https://blog.csdn.net/liuqiker/article/details/103525848?utm_medium=distribute.pc_relevant.none-task-blog-BlogCommendFromBaidu-8.control&depth_1-utm_source=distribute.pc_relevant.none-task-blog-BlogCommendFromBaidu-8.control
https://blog.csdn.net/qq_34745941/article/details/99862327