1、在pom.xml里面加入
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
我发现我的包是红色的,原来是没有导入依赖啊
右侧有这些没安装依赖的包,右击下载就可以了
2、在application.properties里面配置
# 定位模板的目录
spring.thymeleaf.prefix=classpath:/templates/