使用springboot+freemarker时,项目启动时报错:
DEBUG 16:24:07 o.s.w.s.v.f.FreeMarkerConfigurer.getTemplateLoaderForPath 354 :Cannot resolve template loader path [classpath:/templates/] to [java.io.File]: using SpringTemplateLoader as fallback
java.io.FileNotFoundException: class path resource [templates/] cannot be resolved to absolute file path because it does not reside in the file system: jar:file:/E:/maven/apache-maven-3.6.3/repository/com/baomidou/mybatis-plus-generator/3.0.7.1/mybatis-plus-generator-3.0.7.1.jar!/templates/
虽然不影响正常使用,但是看到这个报错还是膈应得很,百度找了资料发现,在application.yml中修改下freemarker的配置可以解决这个报错。
添加 prefer-file-system-access: false。
spring:
#热部署
devtools:
restart:
enabled: true #设置开启热部署
freemarker:
cache: false #页面不加载缓存,修改即时生效
prefer-file-system-access: false #不使用文件系统优先,而使用classpath下的资源文件优先,解决打jar包运行后,出现的异常问题