spring boot集成freemarker

[b]spring boot框架使用了特定的方式来进行配置,从而使开发人员不再需要定义样板化的配置。[/b]

[color=green]第一步创建maven项目,pom.xml配置信息如下:[/color]

org.springframework.boot
spring-boot-starter-parent
1.5.1.RELEASE







org.springframework.boot
spring-boot-starter-web



org.springframework.boot
spring-boot-starter-aop




org.springframework.boot
spring-boot-starter-freemarker




org.apache.commons
commons-lang3
3.2.1




[color=green]第二步,application.properties配置如下:[/color]

#\u670D\u52A1\u5668\u914D\u7F6E\u4FE1\u606F
server.port=8080
server.address=127.0.0.1
server.sessionTimeout=30
server.contextPath=/springboot

#spring boot\u9ED8\u8BA4\u542F\u52A8tomcat\u7684\u8D26\u53F7\u548C\u5BC6\u7801
security.basic.enabled=false

#LOG
logging.config=classpath:log4j2.xml

#MVC
spring.mvc.view.prefix=/WEB-INF/views/
spring.resources.static-locations=classpath:/static/

# 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:/freemarker/
spring.freemarker.settings.template_update_delay=0
spring.freemarker.settings.default_encoding=UTF-8
spring.freemarker.settings.classic_compatible=true
spring.freemarker.order=1


[color=green]第三部项目结构如下:[/color]

[img]http://dl2.iteye.com/upload/attachment/0123/6567/41e04871-36f7-39ad-a65b-54fb804c7c2d.png[/img]


[color=green]项目地址:[url]https://github.com/zhangxia1030/spring-boot-example[/url][/color]

你可能感兴趣的