1.添加依赖(有两种方式)
第一种,在你创建项目的时候就勾选住freemarker,创建完成后就会在你的pom中加入依赖

第二种,在你的pom中加入依赖

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-freemarker</artifactId>
</dependency>
2.application-dev.yml中添加配置文件信息

#Freemarker配置
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
3.在temlates目录下创建一个FreeMaker模板(其实就是一个html的页面,需要把尾缀变成.ftl,因为上述的最后一行配置了,如果不想把尾缀变成.ftl可以去修改上述最后一行的代码[把.ftl变成.html即可])

4.创建一个controller(通过controller来访问freemarker)

5.测试
