@Configuration
public class ThymeleafConfigration { @Bean
public SpringResourceTemplateResolver firstTemplateResolver() {
SpringResourceTemplateResolver templateResolver = new SpringResourceTemplateResolver();
//templateResolver.setPrefix("classpath:/templates2/"); File path = null;
try {
path = new File(ResourceUtils.getURL("classpath:").getPath());
//file:/data/github/testmanagement/target/testmanagement-0.0.1-SNAPSHOT.jar!/BOOT-INF/classes!
System.out.println(path.getPath());
} catch (FileNotFoundException e) {
e.printStackTrace();
}
//server.tomcat.basedir=outsidefile/jacococoverage
String outside_templates=path.getParentFile().getParentFile().getParent()+File.separator;
//String outside_templates=path.getParentFile().getParentFile().getParent()+File.separator+"outsidefile"+File.separator+"jacococoverage"+File.separator; System.out.println(outside_templates);
outside_templates=outside_templates.substring(5,outside_templates.length());
//file:/data/github/testmanagement/target/outsidefile/jacococoverage/ System.out.println("new outside_templates is "+outside_templates);
templateResolver.setPrefix("file://"+outside_templates); templateResolver.setSuffix(".html");
templateResolver.setTemplateMode(TemplateMode.HTML);
templateResolver.setCharacterEncoding("UTF-8");
// templateResolver.setOrder(0);
templateResolver.setCheckExistence(true); //Spring Boot中Thymeleaf引擎动态刷新
templateResolver.setCacheable(false);
return templateResolver;
} // @Bean
// public ClassLoaderTemplateResolver secondaryTemplateResolver() {
// ClassLoaderTemplateResolver secondaryTemplateResolver = new ClassLoaderTemplateResolver();
// secondaryTemplateResolver.setPrefix("templates-2/");
// secondaryTemplateResolver.setSuffix(".html");
// secondaryTemplateResolver.setTemplateMode(TemplateMode.HTML);
// secondaryTemplateResolver.setCharacterEncoding("UTF-8");
// secondaryTemplateResolver.setOrder(1);
// secondaryTemplateResolver.setCheckExistence(true);
//
// return secondaryTemplateResolver;
// }
}

SpringBoot Thymeleaf 配置多个Template Locations的更多相关文章

  1. IDEA SpringBoot +thymeleaf配置

    1.pom添加以下依赖 <dependency> <groupId>org.springframework.boot</groupId> <artifactI ...

  2. springboot+maven+thymeleaf配置实战demo

    本案例使用thymeleaf,与springboot配置使用.thymeleaf是一种模板语言,可以动态或者静态显示文本内容. 1 .项目结构 2.构建springboot项目 通过idea的new ...

  3. Thymeleaf Multiple Template Locations using Spring Boot

    1. Overview In this tutorial, we'll see how we can define multiple template locations using Thymelea ...

  4. SpringBoot自动配置探究

    @SpringBootApplication @SpringBootApplication表示SpringBoot应用,标注在某个类上说明这个类是SpringBoot的主配置类,SpringBoot就 ...

  5. springboot 详细配置2

    # =================================================================== # COMMON SPRING BOOT PROPERTIE ...

  6. springboot中配置主从redis

    测试redis的主从配置 redis实例 文件夹名称如下 redis_master_s redis_slaver1_s redis_slaver2_s redis.conf文件 master的redi ...

  7. 浅谈springboot自动配置原理

    前言 springboot自动配置关键在于@SpringBootApplication注解,启动类之所以作为项目启动的入口,也是因为该注解,下面浅谈下这个注解的作用和实现原理 @SpringBootA ...

  8. SpringBoot下配置FreeMarker配置远程模版

    需求产生原因 要求在同一个接口中,根据不同的参数,返回不同的视图结果 所有的视图中的数据基本一致 要求页面能静态化,优化SEO 例如:A接口返回客户的信息 客户A在调用接口时,返回其个性化定制的页面A ...

  9. SpringBoot+thymeleaf+security+vue搭建后台框架 基础篇(一)

    刚刚接触SpringBoot,说说踩过的坑,主要的还是要记录下来,供以后反省反省! 今天主要讲讲 thymeleaf+security 的搭建,SpringBoot的项目搭建应该比较简单,这里就不多说 ...

随机推荐

  1. Centos7:Redis的安装,配置及使用

    安装依赖与环境 yum install gcc-c++ 解压缩redis 编译,进入redis源码目录 make 安装 make install PREFIX=/usr/local/redis 注:P ...

  2. mysql的decimal(10,0) not null问题

    今天排查一个bug发现开发环境老是报错 order_num 字段insert的时候不能为空,但是发现测试环境没有这个问题. 后来发现测试环境有一个数据库docker安装的mysql 版本是5.7  而 ...

  3. 【Git的基本操作六】分支管理

    分支管理 1. 什么是分支? 在版本控制过程中,使用对条线同时推进多个任务. 2. 分支的好处 同时并行推进多个功能开发,提高开发效率 各个分支在开发过程中,如果某一个分支开发失败,不会对其他分支有任 ...

  4. deep_learning_Function_Sklearn_Mode

    API参考:https://scikit-learn.org/stable/modules/classes.html# 作为Python中经典的机器学习模块,sklearn围绕着机器学习提供了很多可直 ...

  5. windows控制台,cmd,命令提示符下的基础操作

    打开dos命令窗口1.win+r-->运行-->cmd 2.摁住shift+鼠标右击 选择 在此处打开命令窗口3.在磁盘某文件夹下,选择标题栏中输入框,输入cmd 回车 windows下常 ...

  6. datePicker 及 timePicker Diolage弹出对话框式 比较好看的 监听事件

    DatePickerDialog 的监听 new DatePickerDialog(this, new DatePickerDialog.OnDateSetListener() { @Override ...

  7. Django:报错 raise MigrationSchemaMissing("Unable to create the django_migrations table (%s)" % exc)

    Django 执行迁移生成表: python manage.py migrate 报错: raise MigrationSchemaMissing("Unable to create the ...

  8. MariaDB基本命令

    --查看当前日期select current_date();--查看当前时间select current_time();--查看当前日期.时间select now();--查看当前用户select u ...

  9. java学习记录--ThreadLocal使用案例(转)

    本文借由并发环境下使用线程不安全的SimpleDateFormat优化案例,帮助大家理解ThreadLocal. 最近整理公司项目,发现不少写的比较糟糕的地方,比如下面这个: public class ...

  10. Mybatis Generator-自动化生成代码步骤

    链接:https://blog.csdn.net/guo_xl/article/details/86004068 文档:http://mybatis.org/generator/configrefer ...