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 ...
随机推荐
- Linux 网络排错检查思路
Linux 网络排错检查思路 graph TD A[当网络不通时] --> B{ping想要访问的地址,<br>如www.runoob.com} B --> |不通| C{pi ...
- 错误总结Mapper扫描不到
Unsatisfied dependency expressed through field 'baseMapper'; nested exception is org.springframework ...
- 手把手教你搭建SSH框架(Eclipse版)
原文来自公众号[C you again],若需下载完整源码,请在公众号后台回复"ssh". 本期文章详细讲解了SSH(Spring+SpringMVC+Hibernate)框架的搭 ...
- 【JDBC核心】数据库事务
数据库事务 概述 事务是逻辑上的一组操作,或者说一个独立的工作单元.事务内的语句,要么全部执行成功,要么全部执行失败. 事务处理 数据一旦提交,就不可回滚.数据意味着提交的情况: 当一个连接对象被创建 ...
- 【C++】《Effective C++》第四章
第四章 设计与声明 条款18:让接口容易被正确使用,不易被误用 请记住 好的接口很容易被正确使用,不容易被误用.你应该在你的所有接口中努力达到这些性质. "促进正确使用"的办法包括 ...
- Invalid bound statement (not found): com.xxx.xxx.dao.ShopMapper.insertShop
mybatis在编写完SQL,进行测试的时候出现了错误,显示 org.apache.ibatis.binding.BindingException: Invalid bound statement ( ...
- 【Spring】Spring中的Bean - 3、Bean的作用域
Bean的作用域 简单记录-Java EE企业级应用开发教程(Spring+Spring MVC+MyBatis)-Spring中的Bean 通过Spring容器创建一个Bean的实例时,不仅可以完成 ...
- P1273 有线电视网(树形动规,分组背包)
题目链接: https://www.luogu.org/problemnew/show/P1273 题目描述 某收费有线电视网计划转播一场重要的足球比赛.他们的转播网和用户终端构成一棵树状结构,这棵树 ...
- 实现所有SAP设备打印机并行打印
SAP版本:ECC 6.0 701 1.如何实现所有SAP设备打印机并行打印? I.通过事务码:SPAD,进入假脱机管理初始屏幕.点击左上角的菜单中 配置(c)=>输出设备,进入SAP系统 输出 ...
- Pytorch 中张量的理解
张量是一棵树 长久以来,张量和其中维度的概念把我搞的晕头转向. 一维的张量是数组,二维的张量是矩阵,这也很有道理. 但是给一个二维张量,让我算出它每一行的和,应该用 sum(dim=0) 还是 sum ...