maven打jar包并将依赖包打进去


在使用FreeMarker创建Configuration对象时,提示过期

    //freemarker包
    Configuration configuration = new Configuration()~;

查看源码发现,通过此方式获得一个Configuration实例,需要一个版本信息

就是说现在你要获得一个 Configuration实例需要一个版本实例,目前我的版本是2.3.23

Use Configuration(Version) instead.Version是一个静态字段
Configuration.VERSION_2_3_23 是一个静态字段

            //freemarker包
            Configuration configuration = new Configuration(Configuration.VERSION_2_3_23);
            //设置模板加载文件夹
            configuration.setDirectoryForTemplateLoading(new File(ResourceUtils.getURL("classpath:").getPath() + "template"));
            //设置模板
            Template template = configuration.getTemplate("mail.ftl");

微信公众号
在这里插入图片描述


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM