springboot init

springboot init
This commit is contained in:
shimingxy
2019-09-08 23:19:37 +08:00
parent 3c9c422fc7
commit ba4514164e
65 changed files with 2276 additions and 204 deletions

View File

@@ -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);
}
}