spring.freemarker.cache=false
时间: 2024-05-21 07:15:53 浏览: 13
这个配置是用来设置在使用FreeMarker模板引擎时是否开启缓存的。如果设置为false,每次使用模板引擎都会重新加载模板文件,这样可以保证修改模板后立即生效,但是会降低性能。如果设置为true,则会缓存模板,提高性能,但是可能会导致修改模板后不会立即生效。通常在开发阶段可以将其设置为false,而在生产环境中应该设置为true,以提高性能。
相关问题
spring.datasource.url=jdbc:mysql://localhost:3306/debook?characterEncoding=utf-8 spring.datasource.username=root spring.datasource.password=root spring.datasource.driver-class-name=com.mysql.jdbc.Driver spring.datasource.tomcat.initial-size=10 spring.datasource.tomcat.max-active=50 spring.datasource.tomcat.max-idle=30 spring.datasource.tomcat.min-idle=10 spring.freemarker.template-loader-path=classpath:/templates/ spring.freemarker.charset=utf-8 spring.freemarker.cache=false spring.freemarker.expose-request-attributes=true spring.freemarker.expose-session-attributes=true spring.freemarker.expose-spring-macro-helpers=true spring.freemarker.suffix=.ftl spring.jackson.date-format=yyyy-MM-dd spring.jackson.time-zone=GMT+8 mybatis.type-aliases-package=com.de.debook.entity mybatis.mapper-locations=classpath:mapper/*.xml debug=true logging.level.com.de.debook.mapper=debug
这是一个 Spring Boot 应用程序的配置文件,其中包含了一些关于数据库连接、Freemarker 模板引擎的配置以及 MyBatis 的配置。
- 数据库连接:指定了数据库的连接地址、用户名、密码、驱动等信息,使用的是 MySQL 数据库。
- Freemarker 模板引擎:指定了模板文件的路径、字符编码、是否缓存等信息。
- Jackson 序列化:指定了日期格式和时区。
- MyBatis 配置:指定了实体类的包路径和 mapper 文件的位置。
- 日志配置:指定了 com.de.debook.mapper 包下的日志级别为 debug 级别。
其中,debug=true 表示开启调试模式。
spring boot整合 freemarker 详细教程
Spring Boot整合Freemarker的教程如下:
1.在Maven中添加Freemarker依赖:
```xml
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-freemarker</artifactId>
</dependency>
```
2.在application.properties中配置Freemarker相关属性:
```properties
# Freemarker设置
# 模板路径
spring.freemarker.template-loader-path=classpath:/templates/
# 字符编码
spring.freemarker.charset=UTF-8
# 后缀名
spring.freemarker.suffix=.ftl
# 是否开启缓存
spring.freemarker.cache=false
# 内容类型
spring.freemarker.content-type=text/html
```
3.创建Freemarker模板,例如index.ftl:
```html
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Freemarker示例</title>
</head>
<body>
<h1>Hello ${name}!</h1>
</body>
</html>
```
4.创建Controller,例如IndexController:
```java
@Controller
public class IndexController {
@GetMapping("/")
public String index(Model model) {
model.addAttribute("name", "Freemarker");
return "index";
}
}
```
5.运行Spring Boot应用程序,并访问http://localhost:8080/,即可看到渲染后的页面。
以上就是Spring Boot整合Freemarker的详细教程,希望对你有帮助!
相关推荐
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)