SpringBoot中 application.yml /application.properties常用配置介绍
# Tomcat
server:
tomcat:
uri-encoding: UTF-8
max-threads: 1000
min-spare-threads: 30
port: 10444
servlet:
context-path: /admin
#文件上传文件夹
upload:
base:
dir: D:/piyan/upload
basedir: E:/cms spring:
resources:
static-locations: classpath:/META-INF/resources/,classpath:/resources/,classpath:/static/,classpath:/public/,file:${upload.base.dir}
profiles:
active: dev
jackson:
date-format: yyyy-MM-dd HH:mm:ss
time-zone: GMT+8
servlet:
multipart:
max-file-size: 4096MB
max-request-size: 4096MB
enabled: true
freemarker:
suffix: .html
request-context-attribute: request
cache: false
devtools:
restart:
enabled: false
#additional-paths: src/main/java
exclude: WEB-INF/* cmodes:
redis:
open: true # 是否开启redis缓存 true开启 false关闭
shiro:
redis: true # true表示shiro session存到redis里,需要开启redis,才会生效【分布式场景】 #mybatis
mybatis-plus:
mapper-locations: classpath*:mapper/**/*.xml
#实体扫描,多个package用逗号或者分号分隔
typeAliasesPackage: cn.cmodes.modules.*.entity
global-config:
#主键类型 0:"数据库ID自增", 1:"用户输入ID",2:"全局唯一ID (数字类型唯一ID)", 3:"全局唯一ID UUID";
id-type: 2
#字段策略 0:"忽略判断",1:"非 NULL 判断"),2:"非空判断"
field-strategy: 2
#驼峰下划线转换
db-column-underline: true
#刷新mapper 调试神器
refresh-mapper: true
#数据库大写下划线转换
#capital-mode: true
# Sequence序列接口实现类配置
#key-generator: com.baomidou.mybatisplus.incrementer.OracleKeyGenerator
#逻辑删除配置
logic-delete-value: -1
logic-not-delete-value: 0
#自定义填充策略接口实现
#meta-object-handler: com.baomidou.springboot.xxx
#自定义SQL注入器
sql-injector: com.baomidou.mybatisplus.mapper.LogicSqlInjector
configuration:
map-underscore-to-camel-case: true
cache-enabled: false
call-setters-on-nulls: true logging:
level: debug
level.cn.cmodes: debug
path: logs/
file: admin.log
项目中常见配置:
服务端口
服务名称
容器: 类型 如tomcat、undertow 程池大小 请求日志和目录
连接池配置:
sql连接配置
info配置:
模板配置
资源配置
mvc
spring.mvc.async.request-timeout
设定async请求的超时时间,以毫秒为单位,如果没有设置的话,以具体实现的超时时间为准,比如tomcat的servlet3的话是10秒.
spring.mvc.date-format
设定日期的格式,比如dd/MM/yyyy.
spring.mvc.favicon.enabled
是否支持favicon.ico,默认为: true
spring.mvc.ignore-default-model-on-redirect
在重定向时是否忽略默认model的内容,默认为true
spring.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路径开始,默认: messages
spring.messages.cache-seconds
设定加载的资源文件缓存失效时间,-1的话为永不过期,默认为-1
spring.messages.encoding
设定Message bundles的编码,默认: UTF-8
mobile
spring.mobile.devicedelegatingviewresolver.enable-fallback
是否支持fallback的解决方案,默认false
spring.mobile.devicedelegatingviewresolver.enabled
是否开始device view resolver,默认为: false
spring.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
是否开启默认的资源处理,默认为true
spring.resources.cache-period
设定资源的缓存时效,以秒为单位.
spring.resources.chain.cache
是否开启缓存,默认为: true
spring.resources.chain.enabled
是否开启资源 handling chain,默认为false
spring.resources.chain.html-application-cache
是否开启h5应用的cache manifest重写,默认为: false
spring.resources.chain.strategy.content.enabled
是否开启内容版本策略,默认为false
spring.resources.chain.strategy.content.paths
指定要应用的版本的路径,多个以逗号分隔,默认为:[/**]
spring.resources.chain.strategy.fixed.enabled
是否开启固定的版本策略,默认为false
spring.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
是否开启文件上传支持,默认为true
multipart.file-size-threshold
设定文件写入磁盘的阈值,单位为MB或KB,默认为0
multipart.location
指定文件上传路径.
multipart.max-file-size
指定文件大小最大值,默认1MB
multipart.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,以支持热加载,默认为true
spring.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使用velocity
spring.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
是否优先从文件系统加载模板以支持热加载,默认为true
spring.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
是否开启模板缓存,默认true
spring.thymeleaf.check-template-location
是否检查模板路径是否存在,默认true
spring.thymeleaf.content-type
指定Content-Type,默认为: text/html
spring.thymeleaf.enabled
是否允许MVC使用Thymeleaf,默认为: true
spring.thymeleaf.encoding
指定模板的编码,默认为: UTF-8
spring.thymeleaf.excluded-view-names
指定不使用模板的视图名称,多个以逗号分隔.
spring.thymeleaf.mode
指定模板的模式,具体查看StandardTemplateModeHandlers,默认为: HTML5
spring.thymeleaf.prefix
指定模板的前缀,默认为:classpath:/templates/
spring.thymeleaf.suffix
指定模板的后缀,默认为:.html
spring.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
指定模板的后缀,默认: .html
spring.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的变量,默认为: false
spring.groovy.template.configuration.auto-indent
是否在渲染模板时自动缩进,默认为false
spring.groovy.template.configuration.auto-indent-string
如果自动缩进启用的话,是使用SPACES还是TAB,默认为: SPACES
spring.groovy.template.configuration.auto-new-line
渲染模板时是否要输出换行,默认为false
spring.groovy.template.configuration.base-template-class
指定template base class.
spring.groovy.template.configuration.cache-templates
是否要缓存模板,默认为true
spring.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
指定属性要使用双引号还是单引号,默认为false
spring.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,默认为: true
spring.http.converters.preferred-json-mapper
是否优先使用JSON mapper来转换.
spring.http.encoding.charset
指定http请求和相应的Charset,默认: UTF-8
spring.http.encoding.enabled
是否开启http的编码支持,默认为true
spring.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会作为backup
spring.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,默认为: 0
spring.jersey.init
指定传递给Jersey的初始化参数.
spring.jersey.type
指定Jersey的集成类型,可以是servlet或者filter.
注意点:
1,原有的key,例如spring.jpa.properties.hibernate.dialect,按“.”分割,都变成树状的配置
2,key后面的冒号,后面一定要跟一个空格
3,把原有的application.properties删掉。然后一定要执行一下 maven -X clean install
SpringBoot中 application.yml /application.properties常用配置介绍的更多相关文章
- LINUX服务器搭建和常用配置介绍
服务器搭建 : 搭建私有CA服务器 : http://www.cnblogs.com/zhaojiedi1992/p/zhaojiedi_linux_011_ca.html搭建samba服务器 : h ...
- eclipse中的.yml和.properties文件没有绿色叶子图标
0.首先确认正确安装了STS插件 要在eclipse使用spring boot创建项目,必须先安装STS(Spring Tool Suite (STS) for Eclipse),如果网速给力的话可以 ...
- SpringBoot中整合Redis、Ehcache使用配置切换 并且整合到Shiro中
在SpringBoot中Shiro缓存使用Redis.Ehcache实现的两种方式实例 SpringBoot 中配置redis作为session 缓存器. 让shiro引用 本文是建立在你是使用这sh ...
- Springboot中的缓存Cache和CacheManager原理介绍
背景理解 什么是缓存,为什么要用缓存 程序运行中,在内存保持一定时间不变的数据就是缓存.简单到写一个Map,里面放着一些key,value数据,就已经是个缓存了 所以缓存并不是什么高大上的技术,只是个 ...
- application.properties /application.yml官网查看配置;springboot application.properties 官网查看,info yml 查看;springboot.yml查看info;springboot.yml查看Actuator监控中心info
官网查看: https://docs.spring.io/spring-boot/docs/current-SNAPSHOT/reference/htmlsingle/#appendix 查看info ...
- Spring Boot 菜鸟教程 application.properties 常用配置
SPRING CONFIG (ConfigFileApplicationListener) spring.config.name 配置文件名称,默认为application spring.config ...
- SpringBoot中resources配置文件application.properties
#项目名server.servlet.context-path=/springboot-day1#端口号server.port=8989 #datasource数据库连接信息#urlspring.da ...
- 5 — springboot中的yml多环境配置
1.改文件后缀 2.一张截图搞定多环境编写和切换
- springboot中使用自定义的properties属性
在application.properties中添加属性ai.name=明ai.age=22ai.sex=男定义配置类如下,前缀(prefix)可自定义修改,本文为 ai.@Configuration ...
随机推荐
- Python基本数据类型之字符串、数字、布尔
一.数据类型种类 Python中基本数据类型主要有以下几类: Number(数字) String(字符串) Bool (布尔) List(列表) Tuple(元组) Sets(集合) Diction ...
- 535. Encode and Decode TinyURL 长短URL
[抄题]: TinyURL is a URL shortening service where you enter a URL such as https://leetcode.com/problem ...
- 面试题:彻底理解ThreadLocal 索引的利弊 背1
.索引利弊 --整理 1.索引的好处 a.提高数据检索的效率,降低检索过程中必须要读取得数据量,降低数据库IO成本. b.降低数据库的排序成本.因为索引就是对字段数据进行排序后存储的,如果待排序的 ...
- Marr的视觉计算理论
Marr的视觉计算理论立足于计算机科学,系统地概括了心理物理学.神经生理学.临床神经病理学等方面已取得的所有重要成果,是迄今为止最为系统的视觉理论.Marr 的视觉计算理论虽然在细节甚 ...
- 在CentOS6.x下安装Compiz——桌面立方体,特效种种
很多人貌似认为compiz必须要emerland,但事实上,没这个必要. compiz+gnome,实用,而又华丽,是个不错的选择. compiz需要显卡驱动,一般情况下不成问题(别忘了这是很新的ce ...
- MagicNotes:如何迈向工作的坦途
MagicNotes,思绪随风飞扬,不抓住写下来明天就会忘记了. 昨晚在知乎上偶尔看到 @雨农 的关于“为什么我那么努力,吃了那么多苦,也没见那么优秀?”的一个回复,心里有所触动. 本人专科毕业3-4 ...
- 实践作业3:白盒测试----findbugs介绍及使用DAY7
本小组选择的是一个开源的Java静态代码分析工具----Findbugs. 与其他静态分析工具(如Checkstyle和PMD)不同,FindBugs 不注重样式或者格式,它专注于寻找真正的缺陷或者潜 ...
- MySQL性能调优与架构设计——第7章 MySQL数据库锁定机制
第7章 MySQL数据库锁定机制 前言: 为了保证数据的一致完整性,任何一个数据库都存在锁定机制.锁定机制的优劣直接应想到一个数据库系统的并发处理能力和性能,所以锁定机制的实现也就成为了各种数据库的核 ...
- 删除一个数的K位使原数变得最小
原创 给定一个n位正整数a, 去掉其中k个数字后按原左右次序将组成一个新的正整数.对给定的a, k寻找一种方案,使得剩下的数字组成的新数最小. 提示:应用贪心算法设计求解 操作对象为n位正整数,有可能 ...
- Entity Framework 6 初体验
Entity Framework中有三种模式 Code First, Model First和Database First, Code First 是在EF4中新增的模式, 也跟NHibernate等 ...