在前几节中我们讲了SpringBoot中集成freemarker及其相关功能的使用。这篇文章我们从源码层面来看看,SpringBoot中freemarker相关的自动配置源码。
本篇文章源码以SpringBoot2.2.2版本为例。
FreeMarkerProperties
首先看对应application.properties的属性类FreeMarkerProperties。该类继承自AbstractTemplateViewResolverProperties,也就是为前端视图显示配置的抽象类。既然是继承,也就拥有了该父类同样的属性配置。
@ConfigurationProperties(prefix = "spring.freemarker")
public class FreeMarkerProperties extends AbstractTemplateViewResolverProperties {
public static final String DEFAULT_TEMPLATE_LOADER_PATH = "classpath:/templates/";
public static final String DEFAULT_PREFIX = "";
public static final String DEFAULT_SUFFIX = ".ftlh";
/**
* Well-known FreeMarker keys which are passed to FreeMarker's Configuration.
*/
private Map<String, String> settings = new HashMap<>();
/**
* Comma-separated list of template paths.
*/
private String[] templateLoaderPath = new String[] { DEFAULT_TEMPLATE_LOADER_PATH };
// ...
}
转载:https://blog.csdn.net/wo541075754/article/details/103953506
查看评论