SpringBoot常用配置
前言:springboot集成了主流的第三方框架,但是需要使用springboot那一套配置方式。但是我这里只列举了非常非常常用的,可以看已发的几篇博客,慢慢会补充。当然官方文档里也有相应的配置,可惜没有注释。
mvc
spring.mvc.async.request-timeout
设定async请求的超时时间,以毫秒为单位,如果没有设置的话,以具体实现的超时时间为准,比如tomcat的servlet3的话是10秒.spring.mvc.date-format
设定日期的格式,比如dd/MM/yyyy.spring.mvc.favicon.enabled
是否支持favicon.ico,默认为: truespring.mvc.ignore-default-model-on-redirect
在重定向时是否忽略默认model的内容,默认为truespring.mvc.locale
指定使用的Locale.spring.mvc.message-codes-resolver-format
指定message codes的格式化策略(PREFIX_ERROR_CODE,POSTFIX_ERROR_CODE).spring.mvc.view.prefix
指定mvc视图的前缀.spring.mvc.view.suffix
指定mvc视图的后缀.
messages
spring.messages.basename
指定message的basename,多个以逗号分隔,如果不加包名的话,默认从classpath路径开始,默认: messagesspring.messages.cache-seconds
设定加载的资源文件缓存失效时间,-1的话为永不过期,默认为-1spring.messages.encoding
设定Message bundles的编码,默认: UTF-8
mobile
spring.mobile.devicedelegatingviewresolver.enable-fallback
是否支持fallback的解决方案,默认falsespring.mobile.devicedelegatingviewresolver.enabled
是否开始device view resolver,默认为: falsespring.mobile.devicedelegatingviewresolver.mobile-prefix
设定mobile端视图的前缀,默认为:mobile/spring.mobile.devicedelegatingviewresolver.mobile-suffix
设定mobile视图的后缀spring.mobile.devicedelegatingviewresolver.normal-prefix
设定普通设备的视图前缀spring.mobile.devicedelegatingviewresolver.normal-suffix
设定普通设备视图的后缀spring.mobile.devicedelegatingviewresolver.tablet-prefix
设定平板设备视图前缀,默认:tablet/spring.mobile.devicedelegatingviewresolver.tablet-suffix
设定平板设备视图后缀.spring.mobile.sitepreference.enabled
是否启用SitePreferenceHandler,默认为: true
view
spring.view.prefix
设定mvc视图的前缀.spring.view.suffix
设定mvc视图的后缀.
resource
spring.resources.add-mappings
是否开启默认的资源处理,默认为truespring.resources.cache-period
设定资源的缓存时效,以秒为单位.spring.resources.chain.cache
是否开启缓存,默认为: truespring.resources.chain.enabled
是否开启资源 handling chain,默认为falsespring.resources.chain.html-application-cache
是否开启h5应用的cache manifest重写,默认为: falsespring.resources.chain.strategy.content.enabled
是否开启内容版本策略,默认为falsespring.resources.chain.strategy.content.paths
指定要应用的版本的路径,多个以逗号分隔,默认为:[/**]spring.resources.chain.strategy.fixed.enabled
是否开启固定的版本策略,默认为falsespring.resources.chain.strategy.fixed.paths
指定要应用版本策略的路径,多个以逗号分隔spring.resources.chain.strategy.fixed.version
指定版本策略使用的版本号spring.resources.static-locations
指定静态资源路径,默认为classpath:[/META-INF/resources/,/resources/, /static/, /public/]以及context:/
multipart
multipart.enabled
是否开启文件上传支持,默认为truemultipart.file-size-threshold
设定文件写入磁盘的阈值,单位为MB或KB,默认为0multipart.location
指定文件上传路径.multipart.max-file-size
指定文件大小最大值,默认1MBmultipart.max-request-size
指定每次请求的最大值,默认为10MB
freemarker
spring.freemarker.allow-request-override
指定HttpServletRequest的属性是否可以覆盖controller的model的同名项spring.freemarker.allow-session-override
指定HttpSession的属性是否可以覆盖controller的model的同名项spring.freemarker.cache
是否开启template caching.spring.freemarker.charset
设定Template的编码.spring.freemarker.check-template-location
是否检查templates路径是否存在.spring.freemarker.content-type
设定Content-Type.spring.freemarker.enabled
是否允许mvc使用freemarker.spring.freemarker.expose-request-attributes
设定所有request的属性在merge到模板的时候,是否要都添加到model中.spring.freemarker.expose-session-attributes
设定所有HttpSession的属性在merge到模板的时候,是否要都添加到model中.spring.freemarker.expose-spring-macro-helpers
设定是否以springMacroRequestContext的形式暴露RequestContext给Spring’s macro library使用spring.freemarker.prefer-file-system-access
是否优先从文件系统加载template,以支持热加载,默认为truespring.freemarker.prefix
设定freemarker模板的前缀.spring.freemarker.request-context-attribute
指定RequestContext属性的名.spring.freemarker.settings
设定FreeMarker keys.spring.freemarker.suffix
设定模板的后缀.spring.freemarker.template-loader-path
设定模板的加载路径,多个以逗号分隔,默认: ["classpath:/templates/"]spring.freemarker.view-names
指定使用模板的视图列表.
velocity
spring.velocity.allow-request-override
指定HttpServletRequest的属性是否可以覆盖controller的model的同名项spring.velocity.allow-session-override
指定HttpSession的属性是否可以覆盖controller的model的同名项spring.velocity.cache
是否开启模板缓存spring.velocity.charset
设定模板编码spring.velocity.check-template-location
是否检查模板路径是否存在.spring.velocity.content-type
设定ContentType的值spring.velocity.date-tool-attribute
设定暴露给velocity上下文使用的DateTool的名spring.velocity.enabled
设定是否允许mvc使用velocityspring.velocity.expose-request-attributes
是否在merge模板的时候,将request属性都添加到model中spring.velocity.expose-session-attributes
是否在merge模板的时候,将HttpSession属性都添加到model中spring.velocity.expose-spring-macro-helpers
设定是否以springMacroRequestContext的名来暴露RequestContext给Spring’s macro类库使用spring.velocity.number-tool-attribute
设定暴露给velocity上下文的NumberTool的名spring.velocity.prefer-file-system-access
是否优先从文件系统加载模板以支持热加载,默认为truespring.velocity.prefix
设定velocity模板的前缀.spring.velocity.properties
设置velocity的额外属性.spring.velocity.request-context-attribute
设定RequestContext attribute的名.spring.velocity.resource-loader-path
设定模板路径,默认为: classpath:/templates/spring.velocity.suffix
设定velocity模板的后缀.spring.velocity.toolbox-config-location
设定Velocity Toolbox配置文件的路径,比如 /WEB-INF/toolbox.xml.spring.velocity.view-names
设定需要解析的视图名称.
thymeleaf
spring.thymeleaf.cache
是否开启模板缓存,默认truespring.thymeleaf.check-template-location
是否检查模板路径是否存在,默认truespring.thymeleaf.content-type
指定Content-Type,默认为: text/htmlspring.thymeleaf.enabled
是否允许MVC使用Thymeleaf,默认为: truespring.thymeleaf.encoding
指定模板的编码,默认为: UTF-8spring.thymeleaf.excluded-view-names
指定不使用模板的视图名称,多个以逗号分隔.spring.thymeleaf.mode
指定模板的模式,具体查看StandardTemplateModeHandlers,默认为: HTML5spring.thymeleaf.prefix
指定模板的前缀,默认为:classpath:/templates/spring.thymeleaf.suffix
指定模板的后缀,默认为:.htmlspring.thymeleaf.template-resolver-order
指定模板的解析顺序,默认为第一个.spring.thymeleaf.view-names
指定使用模板的视图名,多个以逗号分隔.
mustcache
spring.mustache.cache
是否Enable template caching.spring.mustache.charset
指定Template的编码.spring.mustache.check-template-location
是否检查默认的路径是否存在.spring.mustache.content-type
指定Content-Type.spring.mustache.enabled
是否开启mustcache的模板支持.spring.mustache.prefix
指定模板的前缀,默认: classpath:/templates/spring.mustache.suffix
指定模板的后缀,默认: .htmlspring.mustache.view-names
指定要使用模板的视图名.
groovy模板
spring.groovy.template.allow-request-override
指定HttpServletRequest的属性是否可以覆盖controller的model的同名项spring.groovy.template.allow-session-override
指定HttpSession的属性是否可以覆盖controller的model的同名项spring.groovy.template.cache
是否开启模板缓存.spring.groovy.template.charset
指定Template编码.spring.groovy.template.check-template-location
是否检查模板的路径是否存在.spring.groovy.template.configuration.auto-escape
是否在渲染模板时自动排查model的变量,默认为: falsespring.groovy.template.configuration.auto-indent
是否在渲染模板时自动缩进,默认为falsespring.groovy.template.configuration.auto-indent-string
如果自动缩进启用的话,是使用SPACES还是TAB,默认为: SPACESspring.groovy.template.configuration.auto-new-line
渲染模板时是否要输出换行,默认为falsespring.groovy.template.configuration.base-template-class
指定template base class.spring.groovy.template.configuration.cache-templates
是否要缓存模板,默认为truespring.groovy.template.configuration.declaration-encoding
在写入declaration header时使用的编码spring.groovy.template.configuration.expand-empty-elements
是使用<br/>
这种形式,还是<br></br>
这种展开模式,默认为: false)spring.groovy.template.configuration.locale
指定template locale.spring.groovy.template.configuration.new-line-string
当启用自动换行时,换行的输出,默认为系统的line.separator属性的值spring.groovy.template.configuration.resource-loader-path
指定groovy的模板路径,默认为classpath:/templates/spring.groovy.template.configuration.use-double-quotes
指定属性要使用双引号还是单引号,默认为falsespring.groovy.template.content-type
指定Content-Type.spring.groovy.template.enabled
是否开启groovy模板的支持.spring.groovy.template.expose-request-attributes
设定所有request的属性在merge到模板的时候,是否要都添加到model中.spring.groovy.template.expose-session-attributes
设定所有request的属性在merge到模板的时候,是否要都添加到model中.spring.groovy.template.expose-spring-macro-helpers
设定是否以springMacroRequestContext的形式暴露RequestContext给Spring’s macro library使用spring.groovy.template.prefix
指定模板的前缀.spring.groovy.template.request-context-attribute
指定RequestContext属性的名.spring.groovy.template.resource-loader-path
指定模板的路径,默认为: classpath:/templates/spring.groovy.template.suffix
指定模板的后缀spring.groovy.template.view-names
指定要使用模板的视图名称.
http
spring.hateoas.apply-to-primary-object-mapper
设定是否对object mapper也支持HATEOAS,默认为: truespring.http.converters.preferred-json-mapper
是否优先使用JSON mapper来转换.spring.http.encoding.charset
指定http请求和相应的Charset,默认: UTF-8spring.http.encoding.enabled
是否开启http的编码支持,默认为truespring.http.encoding.force
是否强制对http请求和响应进行编码,默认为true
json
spring.jackson.date-format
指定日期格式,比如yyyy-MM-dd HH:mm:ss,或者具体的格式化类的全限定名spring.jackson.deserialization
是否开启Jackson的反序列化spring.jackson.generator
是否开启json的generators.spring.jackson.joda-date-time-format
指定Joda date/time的格式,比如yyyy-MM-dd HH:mm:ss). 如果没有配置的话,dateformat会作为backupspring.jackson.locale
指定json使用的Locale.spring.jackson.mapper
是否开启Jackson通用的特性.spring.jackson.parser
是否开启jackson的parser特性.spring.jackson.property-naming-strategy
指定PropertyNamingStrategy (CAMEL_CASE_TO_LOWER_CASE_WITH_UNDERSCORES)或者指定PropertyNamingStrategy子类的全限定类名.spring.jackson.serialization
是否开启jackson的序列化.spring.jackson.serialization-inclusion
指定序列化时属性的inclusion方式,具体查看JsonInclude.Include枚举.spring.jackson.time-zone
指定日期格式化时区,比如America/Los_Angeles或者GMT+10.
jersey
spring.jersey.filter.order
指定Jersey filter的order,默认为: 0spring.jersey.init
指定传递给Jersey的初始化参数.spring.jersey.type
指定Jersey的集成类型,可以是servlet或者filter.
SpringBoot常用配置的更多相关文章
- SpringBoot常用配置简介
SpringBoot常用配置简介 1. SpringBoot中几个常用的配置的简单介绍 一个简单的Spring.factories # Bootstrap components org.springf ...
- SpringBoot常用配置,引入外部配置文件信息,热加载
SpringBoot的配置文件格式 yml规范 SpringBoot的配置文件支持properties和yml,甚至还支持json. 更推荐使用yml文件格式: yml文件,会根据换行和缩进帮助咱们管 ...
- SpringBoot 常用配置 静态资源访问配置/内置tomcat虚拟文件映射路径
Springboot 再模板引擎中引入Js等文件,出现服务器拒绝访问的错误,需要配置过滤器 静态资源访问配置 @Configuration @EnableWebMvc public class Sta ...
- SpringBoot阿里巴巴Fastjson的一些常用配置
SpringBoot阿里巴巴Fastjson的一些常用配置 @Bean public HttpMessageConverters fastJsonHttpMessageConverters() { F ...
- SpringBoot 入门篇(二) SpringBoot常用注解以及自动配置
一.SpringBoot常用注解二.SpringBoot自动配置机制SpringBoot版本:1.5.13.RELEASE 对应官方文档链接:https://docs.spring.io/spring ...
- dubbo的常用配置(基于注解)
之前记录了基于springboot的dubbo入门案例,今天在此基础上记录dubbo官网介绍的常用属性配置,dubbo读取我们配置的属性时是有优先级的,优先级如下图: 如图所示,优先级的属性依次为虚拟 ...
- SpringBoot常用Starter介绍和整合模板引擎Freemaker、thymeleaf 4节课
1.SpringBoot Starter讲解 简介:介绍什么是SpringBoot Starter和主要作用 1.官网地址:https://docs.spring.io/spring-boot/doc ...
- springboot系列五、springboot常用注解使用说明
一.controller相关注解 1.@Controller 控制器,处理http请求. 2.@RespController Spring4之后新加的注解,原来返回json需要@ResponseBod ...
- Dubbo在开发中的一些常用配置
介绍Dubbo在开发中的一些常用配置,文中内容主要参考dubbo文档配置和示例两节,详细可移步访问 传送站 1. 属性配置方法及加载顺序 属性常用配置方法主要有三种: 第一种是通过启动时在虚拟机参数 ...
随机推荐
- Could not parse multipart servlet request; nested exception is java.io.IOException: The temporary upload location
spring-boot项目,生产环境运行一段时间后,上传图片报错,如下: threw exception [Request processing failed; nested exception is ...
- Spring Enable*高级应用及原理
Enable* 之前的文章用到了一些Enable*开头的注解,比如EnableAsync.EnableScheduling.EnableAspectJAutoProxy.EnableCaching等, ...
- 退役 AFO
noi滚粗了 D类没学校要 回去高考 此博客停止更新 此文章可能会继续更新 看心情 [upd 2017.11.13] 看完今年noip log级别数据结构终于出现辣! 看来noip以后又多了一大块考点 ...
- HDU 2094 产生冠军 dfs加map容器
解题报告:有一群人在打乒乓球比赛,需要在这一群人里面选出一个冠军,现在规定,若a赢了b,b又赢了c那么如果a与c没有比赛的话,就默认a赢了c,而如果c赢了a的话,则这三个人里面选不出冠军,还有就是如果 ...
- 【leetcode 简单】 第五十八题 计数质数
统计所有小于非负整数 n 的质数的数量. 示例: 输入: 10 输出: 4 解释: 小于 10 的质数一共有 4 个, 它们是 2, 3, 5, 7 . class Solution: def cou ...
- linux命令-grep+正则表达式用法
目标文件/etc/passwd,使用grep命令或egrep 1.显示出所有含有root的行:egrep 'root' passwd 2.输出任何包含bash的所有行,还要输出紧接着这行的上下各两行的 ...
- linux快速复制大量小文件方法 nc+tar【转】
1,在需要对大量小文件进行移动或复制时,用cp.mv都会显得很没有效率,可以用tar先压缩再解压缩的方式. 2,在网络环境中传输时,可以再结合nc命令,通过管道和tcp端口进行传输. nc和tar ...
- 007_苹果Mac系统锁屏不待机效果设置方法介绍
Mac如何设置锁屏不断网?Mac如何设置锁屏不待机?这是一个非常麻烦的设置,有时候一锁屏幕电脑就跟着待机了,这非常的麻烦,所以今天小编就用图文教程的方式教大家Mac如何设置锁屏不断网Mac如何设置锁屏 ...
- docker stack 部署 redis
=============================================== 2019/4/16_第2次修改 ccb_warlock 更新 ...
- 在Mac上搭建ReactNative开发环境
1.安装Homebrew, Mac系统的包管理器,用于安装NodeJS和一些其他必需的工具软件. /usr/bin/ruby -e "$(curl -fsSL https://raw.g ...