Cannot resolve template loader path [classpath:/templates/] to [java.io.File](Freemarker使用jar中的模板)

使用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包运行后,出现的异常问题
  • 2
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值