一、异常信息
Cannot find template location: classpath:/templates/ (please add some templates or check your Thymeleaf configuration)。
找不到模板位置:classpath:/ templates /(请添加一些模板或检查您的Thymeleaf配置)
原因:
SpringBoot会自动从/src/main/resources/templates目录获取Thymeleaf模板引擎,若该目录缺失,就会报该警告。
二、解决方法
方法1:
创建该目录
方法2:
在application.yml中加入以下配置:
thymeleaf:
check-template: false
check-template-location: false
如果是application.properties,就是加入
spring.thymeleaf.check-template=false
spring.thymeleaf.check-template-location=false
方法3:
去掉pom.xml中的以下配置:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
重新运行一下,警告消失
完美解决!