1.该demo功能
http://localhost/system/login展示后台发布新闻列表
http://localhost/前端Freemark模板展示
中间用到了Mysql, Mybatis, druid;可以参考spring-boot相关的demo
2.Pom依赖
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-freemarker</artifactId>
</dependency>
3.项目启动
@SpringBootApplication
@MapperScan(basePackages="com.lance.freemaker.mapper")
public class SimpleApplication {
public static void main(String[] args) {
SpringApplication.run(SimpleApplication.class, args);
}
}
@Configuration
public class WebMvcConfig extends WebMvcConfigurerAdapter{
@Override
public void addInterceptors(InterceptorRegistry registry) {
registry.addInterceptor(new AdminInterceptor()).addPathPatterns("/system/admin/**");
}
}
4.配置freemarker
# FREEMARKER (FreeMarkerAutoConfiguration)
spring.freemarker.allow-request-override=false
spring.freemarker.allow-session-override=false
spring.freemarker.cache=true
spring.freemarker.charset=UTF-8
spring.freemarker.check-template-location=true
spring.freemarker.content-type=text/html
spring.freemarker.enabled=true
spring.freemarker.expose-request-attributes=false
spring.freemarker.expose-session-attributes=false
spring.freemarker.expose-spring-macro-helpers=true
spring.freemarker.prefer-file-system-access=true
spring.freemarker.suffix=.ftl
spring.freemarker.template-loader-path=classpath:/templates/
spring.freemarker.settings.template_update_delay=0
spring.freemarker.settings.default_encoding=UTF-8
spring.freemarker.settings.classic_compatible=true
spring.freemarker.order=1
5.完整项目参考
https://github.com/leelance/spring-boot-all/tree/master/spring-boot-freemarker
分享到:
相关推荐
spring-boot-scaffold, springboot脚手架,集成jpa freemarker dubbo security为一体
spring-boot-starter-freemarker spring-boot-starter-groovy-templates spring-boot-starter-hateoas spring-boot-starter-hornetq spring-boot-starter-integration spring-boot-...
boot集成freemarker freemarker实现转word 第一步:制作word模板 第二步:word模板转xml文件 第三步:修改xml文件内容(添加freemarker语法) 第四步:修改xml文件后缀为.ftl 第五步:使用freemarker的API语法实现输出...
spring-boot-email-core , it.ozimov:spring-boot-freemarker-email , it.ozimov:spring-boot-mustache-email , it.ozimov:spring-boot-pebble-email , it.ozimov:spring-boot-thymeleaf-email 持续集成: ...
freemarker-2.3.22 druid-1.0.14 mybatis-3.3.0 activemq-5.7.0 quartz-2.2.1 slf4j-1.7.12 logback-1.1.3 guava-18.0 apache-commons-xxx 注意事项 目录结构可参考 ./tree.txt。聪明的你一定知道什么样的文件应该...
spring boot 的项目,该项目已成功集成 actuator(监控)、admin(可视化监控)、logback(日志)、aopLog(通过AOP记录web请求日志)、统一异常处理(json级别和页面级别)、freemarker(模板引擎)、thymeleaf(模板引擎)、...
- Spring Boot 集成 WebFlux 开发反应式 Web 应用 - springboot-dubbo - Spring Boot 集成 Dubbo 的三种方式 - springboot-search - Spring Boot 集成 搜索引擎,包括 elasticsearch、solr - springboot-mq ...
spring boot demo 是一个用来深度学习并实战 spring boot 的项目,目前总共包含 66 个集成demo。该项目已成功集成 actuator(监控)、admin(可视化监控)、logback(日志)、aopLog(通过AOP记录web请求日志)、统一异常...
spring boot demo 是一个用来深度学习并实战 spring boot 的项目,目前总共包含 63 个集成demo,已经完成 52 个。 该项目已成功集成 actuator(监控)、admin(可视化监控)、logback(日志)、aopLog(通过AOP记录web请求...
请使用maven导入打开项目,此Demo使用IntelliJ IDEA创建,请尽可能使用IntelliJ IDEA
该项目已成功集成 actuator(监控)、admin(可视化监控)、logback(日志)、aopLog(通过AOP记录web请求日志)、统一异常处理(json级别和页面级别)、freemarker(模板引擎)、thymeleaf(模板引擎)、Beetl(模板引擎)、Enjoy...
使用Spring boot + FreeMarker 实现代码生成功能,完整案例可以查看 eladmin 项目,教程地址: https://www.ydyno.com/archives/1177.html
SpringBoot学习笔记所有源码集,包括 集成了freemarker、Servlet、拦截器、拦截器、Filter、静态资源处理、启动加载数据、Springboot 日志、JDBC使用、Springboot JPA、Mybatis、动态数据源、集成swagger、集成Redis...
1.40 Spring Boot集成EHCache实现缓存机制 1.41 Spring Boot分布式Session状态保存Redis 1.42 Spring Boot Shiro权限管理 1.43 Spring Boot Shiro权限管理 1.44 Spring Boot Shiro权限管理 1.45 Spring Boot Shiro...
在配置freemarker作为模版时,使用xml作为mvc配置文件,目前用testng进行集成测试无法通过 下载项目之后,运行gradle idea生成idea项目 目录说明 src/main/java/ - 类路径,程序的主要代码,将会编译成项目的class ...
该demo是基于spring boot 2集成hibernate及freemarker的可以运行的最基本的例子。 希望能对大家有帮助。
SpringBoot集成Freemarker+FlyingSaucer实现pdf在线预览.pdf
使用Druid Spring Boot Starter 集成Druid数据库连接池与监控 使用FastJsonHttpMessageConverter,提高JSON序列化速度 集成MyBatis、PageHelper分页插件 提供代码生成器根据表名生成对应的Domain(领域对象)、Mapper...
zo-spring-bootFrom zero to one with Spring Boot###roadmap权限:Shiro (Done)UI:SB Admin 2(Based of Bootstrap 3) (TODO)数据库:hsqldb (Done)持久化:Spring Data JPA (Done)MVC:Spring MVC (Done)Template ...
开发你的第一个Spring Boot应用 v. 11.1. 创建POM vi. 11.2. 添加classpath依赖 vii. 11.3. 编写代码 i. 11.3.1. @RestController和@RequestMapping注解 ii. 11.3.2. @EnableAutoConfiguration注解 iii. 11.3.3. ...