问题描述
从旧项目上搭建了一套新项目,出现了以下错误。
template might not exist or might not be accessible by any of the configured Template Resolvers
原因分析:
主要是由于maven打包时,没有将html打包到class里面。配置一下。
解决方案:
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
<excludes>
<exclude>**/*.xlsx</exclude>
<exclude>**/*.xls</exclude>
<exclude>**/*.ftl</exclude>
<exclude>**/*.html</exclude>
</excludes>
</resource>
<resource>
<directory>src/main/resources</directory>
<filtering>false</filtering>
<includes>
<include>**/*.xlsx</include>
<include>**/*.xls</include>
<include>**/*.ftl</include>
<include>**/*.html</include>
</includes>
</resource>
然后 maven-install 。再到class下面看,已经出现了报错的html。
还有其它的一些原因,请参考:
对于"template might not exist or might not be accessible by any of the configured Template Resolvers"的问题,通常是由于以下几个原因导致的:
-
模板文件不存在:首先需要确认所请求的模板文件是否存在于指定的路径中。如果文件不存在,就会出现该错误。可以检查文件路径是否正确,并确保模板文件存在。
-
模板文件不可访问:如果模板文件存在于指定路径中,但是对于当前用户或应用程序来说没有足够的权限进行访问,也会导致该错误。可以检查文件权限,并确保应用程序有足够的权限来读取模板文件。
-
模板解析器配置错误:该错误还可能是由于模板解析器的配置问题引起的。模板解析器负责将模板文件加载到应用程序中进行解析和渲染。如果解析器的配置有误,可能无法正确找到或访问模板文件。可以检查解析器的配置,并确保它正确地指向了模板文件所在的路径。
综上所述,要解决"template might not exist or might not be accessible by any of the configured Template Resolvers"的问题,需要检查模板文件是否存在、是否可访问,并确保解析器的配置正确。如果问题仍然存在,可能需要进一步排查其他可能的原因。