Spring Boot + Beetl配置问题
2017-04-10 00:00
513 查看
场景:1. 刚开始用Beetl,不是很熟悉
2. 原来的配置出现了beetl classes!/templates错误(最可怕的是原来配置在idea中可以直接跑,打成jar就用不得了)
记录一下当前配置,以后再修改优化。
BeetlConf.java(官网配置):
appliaction.properties:
Controller:
templates目录结构:
loanReqList.btl中include:
Beetl是个好东西,不断学习中...
2. 原来的配置出现了beetl classes!/templates错误(最可怕的是原来配置在idea中可以直接跑,打成jar就用不得了)
记录一下当前配置,以后再修改优化。
BeetlConf.java(官网配置):
@Configuration public class BeetlConf { @Value("${beetl.templatesPath}") String templatesPath;//模板跟目录 @Bean(initMethod = "init", name = "beetlConfig") public BeetlGroupUtilConfiguration getBeetlGroupUtilConfiguration() { BeetlGroupUtilConfiguration beetlGroupUtilConfiguration = new BeetlGroupUtilConfiguration(); try { ClasspathResourceLoader cploder = new ClasspathResourceLoader(BeetlConf.class.getClassLoader(),templatesPath); beetlGroupUtilConfiguration.setResourceLoader(cploder); return beetlGroupUtilConfiguration; } catch (Exception e) { throw new RuntimeException(e); } } @Bean(name = "beetlViewResolver") public BeetlSpringViewResolver getBeetlSpringViewResolver(@Qualifier("beetlConfig") BeetlGroupUtilConfiguration beetlGroupUtilConfiguration) { BeetlSpringViewResolver beetlSpringViewResolver = new BeetlSpringViewResolver(); beetlSpringViewResolver.setContentType("text/html;charset=UTF-8"); beetlSpringViewResolver.setOrder(0); beetlSpringViewResolver.setConfig(beetlGroupUtilConfiguration); return beetlSpringViewResolver; } }
appliaction.properties:
### beetl配置 ## 模板根目录 beetl.templatesPath=/templates
Controller:
@RequestMapping("/home") public String home(Admin u, Model model) { return "/back/home.btl"; }
templates目录结构:
loanReqList.btl中include:
<% include("/back/common/_css.btl"){}%>
Beetl是个好东西,不断学习中...
相关文章推荐
- 解决maven工程中使用spring-boot后导致的profile多环境配置失效的问题
- 一个由于springboot自动配置所产生的问题的解决
- spring boot 1.5.6 配置mybaits-plus 多模块配置 ,出现的问题 总结
- 详解配置spring-boot-actuator时候遇到的一些小问题
- springboot Configuration 获取不到@value配置问题
- Springboot 之 解决IDEA读取properties配置文件的中文乱码问题
- Springboot整合Mybatis的CallSettersOnNulls配置问题
- spring boot 配置文件中文乱码问题
- Springboot 之 解决IDEA读取properties配置文件的中文乱码问题
- 关于springboot的配置注册循序问题
- spring boot jar 打版生产版本 配置文件问题
- 关于Spring boot中读取属性配置文件出现中文乱码的问题的解决
- Spring boot 项目 maven的profile多环境配置 不自动替换变量的问题解决
- Springboot 之 解决IDEA读取properties配置文件的中文乱码问题
- spring boot conditionBean MissingBean @configuration 配置不存在问题
- springboot多个module间多套配置文件的问题
- SpringBoot1.5.2安装配置--1.5.2版本问题
- spring boot整合shiro引用配置文件配置是出现的问题
- spring boot 加载资源路径配置和classpath问题
- 解决eclipse创建spring boot项目加载不到application.properties配置文件的问题