Spring boot freemarker 配置
spring:
datasource:
type: com.alibaba.druid.pool.DruidDataSource
driverClassName: com.mysql.jdbc.Driver
url:
username:
password:
jackson:
time-zone: GMT+8
date-format: yyyy-MM-dd HH:mm:ss
resources:
static-locations: classpath:/static/,classpath:/views/
freemarker:
template-loader-path: classpath:/genCodeTemplateV1/
charset: UTF-8
content-type: text/html
@Autowired
private FreeMarkerConfigurer freeMarkerConfigurer; @Bean
public Configuration getFreeMarkerConfiguration(){
return freeMarkerConfigurer.getConfiguration();
}
private Map<String, Object> productMapperByTemplate(Map<String, Object> data) throws Exception {
ProductCodeDTO productDTO = (ProductCodeDTO)data.get("productCodeDTO");
Map dataOfTemplate = this.productTemplate(productDTO);
String formatedTabName = productDTO.getDtoClassName().substring(0, productDTO.getDtoClassName().indexOf("DTO"));
String templateMapperName = "template_Mapper.java";//模板名称
String fileDir = productDTO.getTargetDir() + productDTO.getMapperPackageName().replaceAll("\\.", "/");
String fileNamePath = productDTO.getTargetDir() + productDTO.getMapperPackageName().replaceAll("\\.", "/") + "/" + productDTO.getMapperClassName() + ".java";
Template template = this.getFreeMarkerConfiguration().getTemplate(templateMapperName);//读取模板内容
FileUtils.forceMkdir(new File(fileDir + "/"));//创建文件路径
OutputStreamWriter out = new OutputStreamWriter(new FileOutputStream(fileNamePath), "UTF-8");
template.process(dataOfTemplate, out); //写入文件
out.flush();
out.close();
productDTO.setFormated_tab_name(formatedTabName);
productDTO.setLower_tab_name(productDTO.getTableName().toLowerCase());
data.put("productCodeDTO", productDTO);
dataOfTemplate.putAll(data);
return dataOfTemplate;
}
Spring boot freemarker 配置的更多相关文章
- 玩转spring boot——properties配置
前言 在以往的java开发中,程序员最怕大量的配置,是因为配置一多就不好统一管理,经常出现找不到配置的情况.而项目中,从开发测试环境到生产环境,往往需要切换不同的配置,如测试数据库连接换成生产数据库连 ...
- spring boot+freemarker+spring security标签权限判断
spring boot+freemarker+spring security标签权限判断 SpringBoot+SpringSecurity+Freemarker项目中在页面上使用security标签 ...
- Spring Boot 揭秘与实战 附录 - Spring Boot 公共配置
Spring Boot 公共配置,配置 application.properties/application.yml 文件中. 摘自:http://docs.spring.io/spring-boot ...
- Spring Boot Freemarker特别篇之contextPath【从零开始学Spring Boot】(转)
需求缘起:有人在群里@我:请教群主大神一个问题,spring boot + freemarker 怎么获取contextPath 头疼死我了,网上没一个靠谱的 .我就看看之前博客中的 [Spring ...
- Spring Boot Freemarker特别篇之contextPath【从零开始学Spring Boot
需求缘起:有人在群里@我:请教群主大神一个问题,spring boot + freemarker 怎么获取contextPath 头疼死我了,网上没一个靠谱的 .我就看看之前博客中的 [Spri ...
- Spring Boot自动配置原理(转)
第3章 Spring Boot自动配置原理 3.1 SpringBoot的核心组件模块 首先,我们来简单统计一下SpringBoot核心工程的源码java文件数量: 我们cd到spring-boot- ...
- Spring boot --- 自动配置
spring boot 自动配置 指的是针对很多spring 应用程序常见的应用功能,spring boot 能自动提供相关配置. spring boot 自动配置加载 Spring boot ...
- Spring Boot 属性配置和使用
Spring Boot 属性配置和使用 Spring Boot 允许通过外部配置让你在不同的环境使用同一应用程序的代码,简单说就是可以通过配置文件来注入属性或者修改默认的配置. Spring Boot ...
- Spring Boot 属性配置和使用(转)
Spring Boot 属性配置和使用 Spring Boot 允许通过外部配置让你在不同的环境使用同一应用程序的代码,简单说就是可以通过配置文件来注入属性或者修改默认的配置. Spring Boot ...
随机推荐
- AgileConfig-如何使用AgileConfig.Client读取配置
前面的文章(AgileConfig基于.NetCore的一个轻量级配置中心,AgileConfig轻量级配置中心 1.1.0 发布,支持应用间配置继承)都是介绍AgileConfig服务端已经控制台是 ...
- Logstash-input-jdbc同步mysql数据到ES - sql_last_value
问题:使用 Logstash-input-jdbc同步mysql到ES, 当中使用了 sql_last_value ,如何重新同步? 答: logstash把上一次同步的最后一条记录id写到 c:\用 ...
- 上传功能-弹窗实现-vue
-引入弹窗页面 import fileUpload from 'src/page/cuApplyManage/fileUpload.vue'; -页面布局 <div> <fileUp ...
- Spring中ApplicationContextAware接口的用法
1.为什么使用AppplicationContextAware? ApplicationContext的BeanFactory 的子类, 拥有更强大的功能,ApplicationContext可以在服 ...
- python数据基本运算处理===循环
一.循环语句 1.while while的循环条件为True,即每次正常循环完毕都会返回判断一次条件 只有读到break才能立刻彻底结束循环,break只能结束本层循环 continue也能立即结束本 ...
- 你真会看idea中的Log吗?
在项目中提交代码时,我们时常忘了自己是否已经update代码或者push代码了,或者以为自己push,但是别人说你的代码没push,其实可以通过idea的Log日志中查看,你会发现里面有三种颜色的标签 ...
- 浅入 .NET Core 中的内存和GC知识
目录 托管代码 自动内存管理 参考资料: [1]https://docs.microsoft.com/zh-cn/dotnet/standard/managed-code [2]:https://do ...
- 第一章计算机网络概述---OSI七层网络模型
局域网和广域网 局域网的简写是LAN,广域网用WAL表示.其实家庭的网络就是一个小型的局域网,一个光猫,一根网线,但是光猫无线信号不太好的话,需要在搞一个路由器. 这时候你的电脑连接到路由器上,路由器 ...
- 【分布式锁的演化】终章!手撸ZK分布式锁!
前言 这应该是分布式锁演化的最后一个章节了,相信很多小伙伴们看完这个章节之后在应对高并发的情况下,如何保证线程安全心里肯定也会有谱了.在实际的项目中也可以参考一下老猫的github上的例子,当然代码没 ...
- 【ORA】ora-39700解决