1. spring:
  2. datasource:
  3. type: com.alibaba.druid.pool.DruidDataSource
  4. driverClassName: com.mysql.jdbc.Driver
  5. url:
  6. username:
  7. password:
  8. jackson:
  9. time-zone: GMT+8
  10. date-format: yyyy-MM-dd HH:mm:ss
  11. resources:
  12. static-locations: classpath:/static/,classpath:/views/
  13. freemarker:
  14. template-loader-path: classpath:/genCodeTemplateV1/
  15. charset: UTF-8
  16. content-type: text/html
  1. @Autowired
  2. private FreeMarkerConfigurer freeMarkerConfigurer;
  3.  
  4. @Bean
  5. public Configuration getFreeMarkerConfiguration(){
  6. return freeMarkerConfigurer.getConfiguration();
  7. }
  1. private Map<String, Object> productMapperByTemplate(Map<String, Object> data) throws Exception {
  2. ProductCodeDTO productDTO = (ProductCodeDTO)data.get("productCodeDTO");
  3. Map dataOfTemplate = this.productTemplate(productDTO);
  4. String formatedTabName = productDTO.getDtoClassName().substring(0, productDTO.getDtoClassName().indexOf("DTO"));
  5. String templateMapperName = "template_Mapper.java";//模板名称
  6. String fileDir = productDTO.getTargetDir() + productDTO.getMapperPackageName().replaceAll("\\.", "/");
  7. String fileNamePath = productDTO.getTargetDir() + productDTO.getMapperPackageName().replaceAll("\\.", "/") + "/" + productDTO.getMapperClassName() + ".java";
  8. Template template = this.getFreeMarkerConfiguration().getTemplate(templateMapperName);//读取模板内容
  9. FileUtils.forceMkdir(new File(fileDir + "/"));//创建文件路径
  10. OutputStreamWriter out = new OutputStreamWriter(new FileOutputStream(fileNamePath), "UTF-8");
  11. template.process(dataOfTemplate, out); //写入文件
  12. out.flush();
  13. out.close();
  14. productDTO.setFormated_tab_name(formatedTabName);
  15. productDTO.setLower_tab_name(productDTO.getTableName().toLowerCase());
  16. data.put("productCodeDTO", productDTO);
  17. dataOfTemplate.putAll(data);
  18. return dataOfTemplate;
  19. }

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. JavaScript同步模式,异步模式及宏任务,微任务队列

    首先JavaScript是单线程的语言,也就是说JS执行环境中,负责执行代码的线程只有一个.一次只能执行一个任务,如果有多个任务的话, 就要排队,然后依次执行,优点就是更安全,更简单.缺点就是遇到耗时 ...

  2. Java并发编程实战(3)- 互斥锁

    我们在这篇文章中主要讨论如何使用互斥锁来解决并发编程中的原子性问题. 目录 概述 互斥锁模型 互斥锁简易模型 互斥锁改进模型 Java世界中的互斥锁 synchronized中的锁和锁对象 synch ...

  3. Mysql性能监控可视化

    前言 ​ 操作系统以及Mysql数据库的实时性能状态数据尤为重要,特别是在有性能抖动的时候,这些实时的性能数据可以快速帮助你定位系统或Mysql数据库的性能瓶颈,镜像你在Linux系统上使用top.i ...

  4. Nginx+FFmpeg实现RTSP转RTMP

    RTSP转RTMP 本次转流采用Centos+Nginx+FFmpeg实现,具体实现如下: 1. 安装Ngxin 安装详细略(可以选择安装阿里的Tengine,官方[下载路径](Download - ...

  5. Redis实战篇(一)搭建Redis实例

    今天是Redis实战系列的第一讲,先从如何搭建一个Redis实例开始. 下面介绍如何在Docker.Windows.Linux下安装. Docker下安装 1.查看可用的 Redis 版本 访问 Re ...

  6. 【JS学习】for-in与for-of

    前言:本博客系列为学习后盾人js教程过程中的记录与产出,如果对你有帮助,欢迎关注,点赞,分享.不足之处也欢迎指正,作者会积极思考与改正. 总述: 名称 遍历 适用 for-in 索引 主要建议白能力对 ...

  7. CPNDet:粗暴地给CenterNet加入two-stage精调,更快更强 | ECCV 2020

    本文为CenterNet作者发表的,论文提出anchor-free/two-stage目标检测算法CPN,使用关键点提取候选框再使用两阶段分类器进行预测.论文整体思路很简单,但CPN的准确率和推理速度 ...

  8. LeetCode454. 四数相加 II

    题目 给定四个包含整数的数组列表 A , B , C , D ,计算有多少个元组 (i, j, k, l) ,使得 A[i] + B[j] + C[k] + D[l] = 0. 分析 关键是如何想到用 ...

  9. 入门OJ:扫雪

    扫雪1 题目描述 大雪履盖了整个城市,市政府要求冬季服务部门尽快将一些街道(列在一份清单中)的积雪清除掉以恢复交通,整个城市由许多交叉路口和街道构成,当然任意两个交叉路口都是直接或间接连通的,清单给出 ...

  10. (数据科学学习手札104)Python+Dash快速web应用开发——回调交互篇(上)

    本文示例代码已上传至我的Github仓库https://github.com/CNFeffery/DataScienceStudyNotes 1 简介 这是我的系列教程Python+Dash快速web ...