首先,你可以访问https://blog.csdn.net/qq_28654327/article/details/89849573#commentsedit排查基本的jar引入,和.yml配置,以及/templates/下没有文件的三种情况
如果上述都不能够解决,可能就是
经过排除,是我的resource中少加了<include>**/*.html</include>,因为检测不到/templates/下的html文件,所以启动的时候一直会报Cannot find template location: classpath:/templates/ (please add some templates or check your Thymeleaf configuration),
所以,在pom中加上下面的代码就可以了
<resource>
<directory>src/main/resources</directory>
<includes>
<include>**/*.yml</include>
<include>**/*.xml</include>
<include>**/*.properties</include>
<!--加载模板文件-->
<include>**/*.html</include>
<!--加载静态文件-->
<include>/static/</include>
</includes>
</resource>