import freemarker.template.Configuration;
import freemarker.template.TemplateModelException;
import org.springframework.stereotype.Component;
import javax.annotation.PostConstruct;
/**
* freemarker配置
*
* @author hjljy
* @date 2021/10/15
*/
@Component
public class FreemarkerConfiguration {
private final Configuration configuration;
public FreemarkerConfiguration(Configuration configuration) {
this.configuration = configuration;
}
/**
* 加载配置变量数据
*
* @throws TemplateModelException 模板模型异常
*/
@PostConstruct
public void loadConfig() throws TemplateModelException {
configuration.setSharedVariable("name", "海加尔金鹰");
configuration.setSharedVariable("url", "https://www.hjljy.cn");
}
}