添加依赖
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
<!-- 热部署插件 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<optional>true</optional>
<scope>runtime</scope>
</dependency>
<!--web-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
.properties文件配置
# \u8bbe\u7f6e\u7aef\u53e3
server.port=8088
# thymeleaf
# \u8bbe\u7f6e\u6a21\u677f\u524d\u7f00
spring.thymeleaf.prefix=classpath:/templates/
spring.thymeleaf.check-template-location=true
# \u8bbe\u7f6e\u6a21\u677f\u540e\u7f00\u540d
spring.thymeleaf.suffix=.html
# \u8bbe\u7f6e\u7f16\u7801\u683c\u5f0f
spring.thymeleaf.content-type=text/html
spring.thymeleaf.mode=HTML5
spring.thymeleaf.cache=false
报错整理
提示模板找不到,先看自己的路径是不是正确的。
然后注意,controller里面有没有加@ResponseBody注解。