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 配置的更多相关文章

  1. 玩转spring boot——properties配置

    前言 在以往的java开发中,程序员最怕大量的配置,是因为配置一多就不好统一管理,经常出现找不到配置的情况.而项目中,从开发测试环境到生产环境,往往需要切换不同的配置,如测试数据库连接换成生产数据库连 ...

  2. spring boot+freemarker+spring security标签权限判断

    spring boot+freemarker+spring security标签权限判断 SpringBoot+SpringSecurity+Freemarker项目中在页面上使用security标签 ...

  3. Spring Boot 揭秘与实战 附录 - Spring Boot 公共配置

    Spring Boot 公共配置,配置 application.properties/application.yml 文件中. 摘自:http://docs.spring.io/spring-boot ...

  4. Spring Boot Freemarker特别篇之contextPath【从零开始学Spring Boot】(转)

    需求缘起:有人在群里@我:请教群主大神一个问题,spring boot  + freemarker 怎么获取contextPath 头疼死我了,网上没一个靠谱的 .我就看看之前博客中的 [Spring ...

  5. Spring Boot Freemarker特别篇之contextPath【从零开始学Spring Boot

      需求缘起:有人在群里@我:请教群主大神一个问题,spring boot  + freemarker 怎么获取contextPath 头疼死我了,网上没一个靠谱的 .我就看看之前博客中的 [Spri ...

  6. Spring Boot自动配置原理(转)

    第3章 Spring Boot自动配置原理 3.1 SpringBoot的核心组件模块 首先,我们来简单统计一下SpringBoot核心工程的源码java文件数量: 我们cd到spring-boot- ...

  7. Spring boot --- 自动配置

    spring boot 自动配置 指的是针对很多spring 应用程序常见的应用功能,spring boot 能自动提供相关配置. spring boot 自动配置加载     Spring boot ...

  8. Spring Boot 属性配置和使用

    Spring Boot 属性配置和使用 Spring Boot 允许通过外部配置让你在不同的环境使用同一应用程序的代码,简单说就是可以通过配置文件来注入属性或者修改默认的配置. Spring Boot ...

  9. Spring Boot 属性配置和使用(转)

    Spring Boot 属性配置和使用 Spring Boot 允许通过外部配置让你在不同的环境使用同一应用程序的代码,简单说就是可以通过配置文件来注入属性或者修改默认的配置. Spring Boot ...

随机推荐

  1. Head First 设计模式 —— 04. 工厂 (Factory) 模式

    思考题 如何将实例化具体类的代码从应用中抽离,或者封装起来,使它们不会干扰应用的其他部分? P111 将实例化具体类的代码放入一个对象中管理,通过不同入参决定实例化具体的类 简单工厂 不是23种GOF ...

  2. 附录 A ES6附加特性

    目录 模板字符串 解构 对象的解构 数组的解构 增强版对象字面量 模板字符串 const student = { name: "Wango", age: 24, } // 普通字符 ...

  3. maven打包时排除配置文件

    上网查了一下,直接在pom里面配置就好了,具体写法如下所示 <build> ... <resources> <resource> <directory> ...

  4. jenkins + Ansible Plugin + ansi-color 让结果显示颜色

    1 安装jenkins: 此处省略百余字......   2 安装jenkins的插件: Ansible Plugin AnsiColor Plugin    3 设置job 内容 让ansible ...

  5. 【分布式锁的演化】终章!手撸ZK分布式锁!

    前言 这应该是分布式锁演化的最后一个章节了,相信很多小伙伴们看完这个章节之后在应对高并发的情况下,如何保证线程安全心里肯定也会有谱了.在实际的项目中也可以参考一下老猫的github上的例子,当然代码没 ...

  6. 【Linux】NFS搭建及使用详解

    环境:CentOS release 6.8 server  192.168.25.100 client1 192.168.25.101 client2 192.168.25.102 1.服务端操作 1 ...

  7. ctfshow—web—web5

    打开靶机,代码审计 附上代码 <?php error_reporting(0); ?> <html lang="zh-CN"> <head> & ...

  8. 利用vbs隐藏dos窗口

    方法一: option explicitdim wshshellset wshshell=wscript.createobject("wscript.shell")wshshell ...

  9. Python编程小技巧(一)

    在使用Tkinter编写代码的时候,有时候会忘记某个组件的参数是什么或者忘记某个参数怎么拼写的,此时可以通过如下方式查询组件的参数列表,以按钮组件为例: 1 # -*- coding:utf-8 -* ...

  10. CentOS 7 下安装 mysql ,以及用到的命令

    VMware虚拟机装好后,再装个CentOS7系统,以上环境自行百度... 一.Linux下查看mysql是否安装 1.指令ps -ef|grep mysql [root@localhost 桌面]# ...