mirror of
https://gitee.com/dromara/MaxKey.git
synced 2026-05-15 13:02:07 +08:00
springboot init
springboot init
This commit is contained in:
@@ -5,8 +5,9 @@ import java.util.Map;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
|
||||
import org.maxkey.web.tag.BaseTagDirective;
|
||||
import org.maxkey.web.tag.FreemarkerTag;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.BeansException;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
@@ -18,22 +19,20 @@ import freemarker.template.TemplateException;
|
||||
|
||||
@Component
|
||||
public class MaxKeyFreeMarkerConfigurer implements ApplicationContextAware {
|
||||
|
||||
private static final Logger _logger = LoggerFactory.getLogger(MaxKeyFreeMarkerConfigurer.class);
|
||||
ApplicationContext applicationContext ;
|
||||
|
||||
@Autowired
|
||||
Configuration configuration;
|
||||
|
||||
@Autowired
|
||||
BaseTagDirective baseTagDirective;
|
||||
|
||||
|
||||
@PostConstruct // 在项目启动时执行方法
|
||||
public void setSharedVariable() throws IOException, TemplateException {
|
||||
// configuration.setSharedVariable("base", baseTagDirective);
|
||||
// 根据注解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.debug("FreeMarker Template "+key);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user