启动加入Thymeleaf依赖启动器的一个Spring Boot项目后,控制台日志出现警告信息:Cannot find template location: classpath:/templates/…
1、警告信息
... 2021-10-13 15:35:39.086 WARN 21460 --- [ restartedMain] ion$DefaultTemplateResolverConfiguration : Cannot find template location: classpath:/templates/ (please add some templates or check your Thymeleaf configuration) ...
2、原因分析
templates找不到相关文件。
3、解决方案 3.1、全局配置文件
在全局配置文件application.properties或application.yml中加入以下内容可让该警告提示不再出现。
######################################################## ###Thymeleaf ######################################################## #spring.thymeleaf.check-template=false #spring.thymeleaf.check-template-location=false3.2、模版文件
在templates目录新建一个*.html的文件作为模版文件后,重新运行主启动类Application,该警告提示不再出现。



