错误记录:
DEBUG 14084 --- [ main] o.s.w.s.v.f.FreeMarker
Configurer : Cannot resolve template loader path [classpath:/templates/]
to [java.io.File]: using SpringTemplateLoader as fallback
java.io.FileNotFoundException: class path resource [templates/] cannot be resolv
ed to absolute file path because it does not reside in the file system: jar:file
:/C:/app/upload/clouddisk-server-0.0.1-SNAPSHOT.war!/WEB-INF/classes!/templates/
以jar包部署的时候启动抛出以下异常
但是不影响正常启动,
请看这个类的源码
FreeMarkerConfigurationFactory中存在以下方法 protected TemplateLoader getTemplateLoaderForPath(String templateLoaderPath) {。。。。。}
这没什么好担心的。 请注意,日志级别是DEBUG,而不是ERROR或WARNING。
当模板目录可以通过java.io.File访问时(因为它不在jar,war等中),Spring将配置FreeMarker直接使用java.io.File加载模板,因为FreeMarker可以检查 上次修改时间并自动重新加载模板。 为了确定路径是否可以映射到普通目录,Spring将调用Resource.getFile()并查看它是否抛出IOException。 如果是这样,Spring会使用DEBUG级别进行日志记录,然后将FreeMarker配置为通过Spring的Resource抽象加载模板(当然不使用Resource.getFile)。 所以这是你案例中的正常程序流程。
解决办法:把spring的日志级别换成INFO即可
<logger name="org.springframework.web" level="INFO"/>