我是用springboot设置邮件发送模版的时候,遇到了这个问题,具体模版可参考:一看就会的Spring boot 发送邮件 + 使用html模板发送邮件_springboot发送html邮件_liTianQi.的博客-CSDN博客
用maven管理的,在获取资源时候 :
Resource resource = new ClassPathResource("mailtemplate.ftl");
发现一直显示无法找到,信息如下:
class path resource [xxx.ftl] cannot be opened because it does not exist,
解决方案:在你的pom.xml里面加入对应资源过滤
<resources>
<resource>
<directory>src/main/java</directory>
<includes>
<include>**/*.properties</include>
<include>**/*.xml</include>
<include>**/*.yml</include>
<include>**/Dockerfile</include>
<include>**/*.xlsx</include>
<include>**/*.ftl</include>
</includes>
</resource>
</resources>