SpringBoot 集成FreeMarker 时出现如下错误信息:java.io.FileNotFoundException: class path resource [templates] cannot be resolved to URL because it does not exist
大致意思:templates 文件夹不存在。
第一:排除classpath 路径指向问题:
普通写法
spring.freemarker.template-loader-path=classpath:/templates
推荐写法
spring.freemarker.template-loader-path=classpath*:/templates
第二:判断项目的编译目录是否产生templates 文件夹。
![](https://img-blog.csdnimg.cn/20190410151928585.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3pob3V6aGl3ZW5nYW5n,size_16,color_FFFFFF,t_70)
第一种解决办法:如果编译目录的下不存在资源文件,那么编译不成功, 解决办法也很简单,选择Eclipse 工具栏上的Project , 选择clean up ,并勾选下面的 Build Automatically,这样就会自动编译了,等编译完成,你再看编辑文件目录,是否存在资源文件,存在了,则问题解决。
第二种解决办法:直接在编译文件目录,新建缺少的文件夹目录。