企业🤖AI智能体构建引擎,智能编排和调试,一键部署,支持私有化部署方案 广告
``` /** * @author 张跃帅 * @Description: beetl-自动配置 * @date 2018/10/22 */ @Configuration public class ProBeetlConfig { /** * 开启热加载 */ private final String beetlDev = "true"; /** * 模板根目录 */ private final String templatesPath = "templates"; /** * 模板后缀 */ //private final String suffix = ".html"; @Bean(name = "beetlConfig") protected BeetlGroupUtilConfiguration getBeetlGroupUtilConfiguration() { // beetl配置对象 BeetlGroupUtilConfiguration beetlGroupConfig = new BeetlGroupUtilConfiguration(); // 创建beetl参数对象 Properties beetlProperties = new Properties(); // 设置参数 beetlProperties.put("RESOURCE.autoCheck", this.beetlDev); // 获取SpringBoot的ClassLoader ClassLoader loader = Thread.currentThread().getContextClassLoader(); // 判断 if (null == loader) { loader = ProBeetlConfig.class.getClassLoader(); } // 创建类路径资源加载器 ClasspathResourceLoader cploder = new ClasspathResourceLoader(loader, this.templatesPath); // 设置 beetlGroupConfig.setConfigProperties(beetlProperties); beetlGroupConfig.setResourceLoader(cploder); // 初始化 beetlGroupConfig.init(); // 返回 return beetlGroupConfig; } @Bean(name = "beetlViewResolver") protected BeetlSpringViewResolver getBeetlSpringViewResolver(@Qualifier("beetlConfig") BeetlGroupUtilConfiguration beetlGroupConfig) { // 创建beetl模板引擎视图解析对象 BeetlSpringViewResolver beetlView = new BeetlSpringViewResolver(); // 设置 beetlView.setContentType("text/html; charset=UTF-8"); beetlView.setOrder(0); beetlView.setConfig(beetlGroupConfig); // 返回 return beetlView; } }