Update ConfigurerFreeMarker.java

This commit is contained in:
MaxKey
2024-06-01 11:48:37 +08:00
parent 04050483de
commit e8057b4661

View File

@@ -17,7 +17,6 @@
package org.dromara.maxkey.web;
import java.io.IOException;
import java.util.Map;
@@ -42,15 +41,14 @@ public class ConfigurerFreeMarker implements ApplicationContextAware {
@Autowired
Configuration configuration;
@PostConstruct // 在项目启动时执行方法
public void setSharedVariable() throws IOException, TemplateException {
public void setSharedVariable() throws TemplateException {
// 根据注解FreemarkerTag获取bean ,key is bean name ,value is bean object
Map<String, Object> map = this.applicationContext.getBeansWithAnnotation(FreemarkerTag.class);
for (String key : map.keySet()) {
configuration.setSharedVariable(key, map.get(key));
_logger.trace("FreeMarker Template "+key);
for (Map.Entry<String, Object> entry : map.entrySet()) {
configuration.setSharedVariable(entry.getKey(), entry.getValue());
_logger.trace("FreeMarker Template {}" , entry.getKey());
}
}