zoukankan      html  css  js  c++  java
  • Spring Boot 菜鸟教程 application.properties 常用配置

    SPRING CONFIG (ConfigFileApplicationListener)

    spring.config.name
    配置文件名称,默认为application
    spring.config.location
    配置文件存放位置,默认为classpath目录下

    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>这种展开模式,默认为: 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.

    PROFILES

    spring.profiles.active= # comma list of active profiles
    spring.profiles.include= # unconditionally activate the specified comma separated profiles

    APPLICATION SETTINGS (SpringApplication)

    spring.main.sources=
    spring.main.web-environment= # detect by default
    spring.main.show-banner=true
    spring.main....= # see class for all properties

    LOGGING

    logging.path=/var/logs
    logging.file=myapp.log
    logging.config= # location of config file (default classpath:logback.xml for logback)
    logging.level.*= # levels for loggers, e.g. "logging.level.org.springframework=DEBUG" (TRACE, DEBUG, INFO, WARN, ERROR, FATAL, OFF)

    IDENTITY (ContextIdApplicationContextInitializer)

    spring.application.name=
    spring.application.index=

    EMBEDDED SERVER CONFIGURATION (ServerProperties)

    server.port=8080
    server.address= # bind to a specific NIC
    server.session-timeout= # session timeout in seconds
    server.context-parameters.*= # Servlet context init parameters, e.g. server.context-parameters.a=alpha
    server.context-path= # the context path, defaults to '/'
    server.servlet-path= # the servlet path, defaults to '/'
    server.ssl.enabled=true # if SSL support is enabled
    server.ssl.client-auth= # want or need
    server.ssl.key-alias=
    server.ssl.ciphers= # supported SSL ciphers
    server.ssl.key-password=
    server.ssl.key-store=
    server.ssl.key-store-password=
    server.ssl.key-store-provider=
    server.ssl.key-store-type=
    server.ssl.protocol=TLS
    server.ssl.trust-store=
    server.ssl.trust-store-password=
    server.ssl.trust-store-provider=
    server.ssl.trust-store-type=
    server.tomcat.access-log-pattern= # log pattern of the access log
    server.tomcat.access-log-enabled=false # is access logging enabled
    server.tomcat.internal-proxies=10.d{1,3}.d{1,3}.d{1,3}|
    192.168.d{1,3}.d{1,3}|
    169.254.d{1,3}.d{1,3}|
    127.d{1,3}.d{1,3}.d{1,3} # regular expression matching trusted IP addresses
    server.tomcat.protocol-header=x-forwarded-proto # front end proxy forward header
    server.tomcat.port-header= # front end proxy port header
    server.tomcat.remote-ip-header=x-forwarded-for
    server.tomcat.basedir=/tmp # base dir (usually not needed, defaults to tmp)
    server.tomcat.background-processor-delay=30; # in seconds
    server.tomcat.max-http-header-size= # maximum size in bytes of the HTTP message header
    server.tomcat.max-threads = 0 # number of threads in protocol handler
    server.tomcat.uri-encoding = UTF-8 # character encoding to use for URL decoding

    SPRING MVC (WebMvcProperties)

    spring.mvc.locale= # set fixed locale, e.g. en_UK
    spring.mvc.date-format= # set fixed date format, e.g. dd/MM/yyyy
    spring.mvc.message-codes-resolver-format= # PREFIX_ERROR_CODE / POSTFIX_ERROR_CODE
    spring.mvc.ignore-default-model-on-redirect=true # If the the content of the "default" model should be ignored redirects
    spring.view.prefix= # MVC view prefix
    spring.view.suffix= # ... and suffix
    spring.resources.cache-period= # cache timeouts in headers sent to browser
    spring.resources.add-mappings=true # if default mappings should be added

    SPRING HATEOS (HateoasProperties)

    spring.hateoas.apply-to-primary-object-mapper=true # if the primary mapper should also be configured

    HTTP encoding (HttpEncodingProperties)

    spring.http.encoding.charset=UTF-8 # the encoding of HTTP requests/responses
    spring.http.encoding.enabled=true # enable http encoding support
    spring.http.encoding.force=true # force the configured encoding

    JACKSON (JacksonProperties)

    spring.jackson.date-format= # Date format string (e.g. yyyy-MM-dd HH:mm:ss), or a fully-qualified date format class name (e.g. com.fasterxml.jackson.databind.util.ISO8601DateFormat)
    spring.jackson.property-naming-strategy= # One of the constants on Jackson's PropertyNamingStrategy (e.g. CAMEL_CASE_TO_LOWER_CASE_WITH_UNDERSCORES) or the fully-qualified class name of a PropertyNamingStrategy subclass
    spring.jackson.deserialization.= # see Jackson's DeserializationFeature
    spring.jackson.generator.
    = # see Jackson's JsonGenerator.Feature
    spring.jackson.mapper.= # see Jackson's MapperFeature
    spring.jackson.parser.
    = # see Jackson's JsonParser.Feature
    spring.jackson.serialization.*= # see Jackson's SerializationFeature

    THYMELEAF (ThymeleafAutoConfiguration)

    spring.thymeleaf.check-template-location=true
    spring.thymeleaf.prefix=classpath:/templates/
    spring.thymeleaf.excluded-view-names= # comma-separated list of view names that should be excluded from resolution
    spring.thymeleaf.view-names= # comma-separated list of view names that can be resolved
    spring.thymeleaf.suffix=.html
    spring.thymeleaf.mode=HTML5
    spring.thymeleaf.encoding=UTF-8
    spring.thymeleaf.content-type=text/html # ;charset=<encoding> is added
    spring.thymeleaf.cache=true # set to false for hot refresh

    REEMARKER (FreeMarkerAutoConfiguration)

    spring.freemarker.allow-request-override=false
    spring.freemarker.cache=true
    spring.freemarker.check-template-location=true
    spring.freemarker.charset=UTF-8
    spring.freemarker.content-type=text/html
    spring.freemarker.expose-request-attributes=false
    spring.freemarker.expose-session-attributes=false
    spring.freemarker.expose-spring-macro-helpers=false
    spring.freemarker.prefix=
    spring.freemarker.request-context-attribute=
    spring.freemarker.settings.*=
    spring.freemarker.suffix=.ftl
    spring.freemarker.template-loader-path=classpath:/templates/ # comma-separated list
    spring.freemarker.view-names= # whitelist of view names that can be resolved

    GROOVY TEMPLATES (GroovyTemplateAutoConfiguration)

    spring.groovy.template.cache=true
    spring.groovy.template.charset=UTF-8
    spring.groovy.template.configuration.*= # See Groovy's TemplateConfiguration
    spring.groovy.template.content-type=text/html
    spring.groovy.template.prefix=classpath:/templates/
    spring.groovy.template.suffix=.tpl
    spring.groovy.template.view-names= # whitelist of view names that can be resolved

    VELOCITY TEMPLATES (VelocityAutoConfiguration)

    spring.velocity.allow-request-override=false
    spring.velocity.cache=true
    spring.velocity.check-template-location=true
    spring.velocity.charset=UTF-8
    spring.velocity.content-type=text/html
    spring.velocity.date-tool-attribute=
    spring.velocity.expose-request-attributes=false
    spring.velocity.expose-session-attributes=false
    spring.velocity.expose-spring-macro-helpers=false
    spring.velocity.number-tool-attribute=
    spring.velocity.prefer-file-system-access=true # prefer file system access for template loading
    spring.velocity.prefix=
    spring.velocity.properties.*=
    spring.velocity.request-context-attribute=
    spring.velocity.resource-loader-path=classpath:/templates/
    spring.velocity.suffix=.vm
    spring.velocity.toolbox-config-location= # velocity Toolbox config location, for example "/WEB-INF/toolbox.xml"
    spring.velocity.view-names= # whitelist of view names that can be resolved

    JERSEY (JerseyProperties)

    spring.jersey.type=servlet # servlet or filter
    spring.jersey.init= # init params
    spring.jersey.filter.order=

    INTERNATIONALIZATION (MessageSourceAutoConfiguration)

    spring.messages.basename=messages
    spring.messages.cache-seconds=-1
    spring.messages.encoding=UTF-8

    SECURITY (SecurityProperties)

    security.user.name=user # login username
    security.user.password= # login password
    security.user.role=USER # role assigned to the user
    security.require-ssl=false # advanced settings ...
    security.enable-csrf=false
    security.basic.enabled=true
    security.basic.realm=Spring
    security.basic.path= # /**
    security.filter-order=0
    security.headers.xss=false
    security.headers.cache=false
    security.headers.frame=false
    security.headers.content-type=false
    security.headers.hsts=all # none / domain / all
    security.sessions=stateless # always / never / if_required / stateless
    security.ignored=false

    DATASOURCE (DataSourceAutoConfiguration & DataSourceProperties)

    spring.datasource.name= # name of the data source  
    spring.datasource.initialize=true # populate using data.sql  
    spring.datasource.schema= # a schema (DDL) script resource reference  
    spring.datasource.data= # a data (DML) script resource reference  
    spring.datasource.sql-script-encoding= # a charset for reading SQL scripts  
    spring.datasource.platform= # the platform to use in the schema resource (schema-${platform}.sql)  
    spring.datasource.continue-on-error=false # continue even if can't be initialized  
    spring.datasource.separator=; # statement separator in SQL initialization scripts  
    spring.datasource.driver-class-name= # JDBC Settings...  
    spring.datasource.url=  
    spring.datasource.username=  
    spring.datasource.password=  
    spring.datasource.jndi-name= # For JNDI lookup (class, url, username & password are ignored when set)  
    spring.datasource.max-active=100 # Advanced configuration...  
    spring.datasource.max-idle=8  
    spring.datasource.min-idle=8  
    spring.datasource.initial-size=10  
    spring.datasource.validation-query=  
    spring.datasource.test-on-borrow=false  
    spring.datasource.test-on-return=false  
    spring.datasource.test-while-idle=  
    spring.datasource.time-between-eviction-runs-millis=  
    spring.datasource.min-evictable-idle-time-millis=  
    spring.datasource.max-wait=  
    spring.datasource.jmx-enabled=false # Export JMX MBeans (if supported) 
    spring.dao.exceptiontranslation.enabled
    是否开启PersistenceExceptionTranslationPostProcessor,默认为true
    spring.datasource.abandon-when-percentage-full
    设定超时被废弃的连接占到多少比例时要被关闭或上报
    spring.datasource.allow-pool-suspension
    使用Hikari pool时,是否允许连接池暂停,默认为: false
    spring.datasource.alternate-username-allowed
    是否允许替代的用户名.
    spring.datasource.auto-commit
    指定updates是否自动提交.
    spring.datasource.catalog
    指定默认的catalog.
    spring.datasource.commit-on-return
    设置当连接被归还时,是否要提交所有还未完成的事务
    spring.datasource.connection-init-sql
    指定连接被创建,再被添加到连接池之前执行的sql.
    spring.datasource.connection-init-sqls
    使用DBCP connection pool时,指定初始化时要执行的sql
    spring.datasource.connection-properties.[key]
    在使用DBCP connection pool时指定要配置的属性
    spring.datasource.connection-test-query
    指定校验连接合法性执行的sql语句
    spring.datasource.connection-timeout
    指定连接的超时时间,毫秒单位.
    spring.datasource.continue-on-error
    在初始化数据库时,遇到错误是否继续,默认false
    spring.datasource.data
    指定Data (DML)脚本
    spring.datasource.data-source-class-name
    指定数据源的全限定名.
    spring.datasource.data-source-jndi
    指定jndi的地址
    spring.datasource.data-source-properties.[key]
    使用Hikari connection pool时,指定要设置的属性
    spring.datasource.db-properties
    使用Tomcat connection pool,指定要设置的属性
    spring.datasource.default-auto-commit
    是否自动提交.
    spring.datasource.default-catalog
    指定连接默认的catalog.
    spring.datasource.default-read-only
    是否设置默认连接只读.
    spring.datasource.default-transaction-isolation
    指定连接的事务的默认隔离级别.
    spring.datasource.driver-class-name
    指定driver的类名,默认从jdbc url中自动探测.
    spring.datasource.fair-queue
    是否采用FIFO返回连接.
    spring.datasource.health-check-properties.[key]
    使用Hikari connection pool时,在心跳检查时传递的属性
    spring.datasource.idle-timeout
    指定连接多久没被使用时,被设置为空闲,默认为10ms
    spring.datasource.ignore-exception-on-pre-load
    当初始化连接池时,是否忽略异常.
    spring.datasource.init-sql
    当连接创建时,执行的sql
    spring.datasource.initial-size
    指定启动连接池时,初始建立的连接数量
    spring.datasource.initialization-fail-fast
    当创建连接池时,没法创建指定最小连接数量是否抛异常
    spring.datasource.initialize
    指定初始化数据源,是否用data.sql来初始化,默认: true
    spring.datasource.isolate-internal-queries
    指定内部查询是否要被隔离,默认为false
    spring.datasource.jdbc-interceptors
    使用Tomcat connection pool时,指定jdbc拦截器,分号分隔
    spring.datasource.jdbc-url
    指定JDBC URL.
    spring.datasource.jmx-enabled
    是否开启JMX,默认为: false
    spring.datasource.jndi-name
    指定jndi的名称.
    spring.datasource.leak-detection-threshold
    使用Hikari connection pool时,多少毫秒检测一次连接泄露.
    spring.datasource.log-abandoned
    使用DBCP connection pool,是否追踪废弃statement或连接,默认为: false
    spring.datasource.log-validation-errors
    当使用Tomcat connection pool是否打印校验错误.
    spring.datasource.login-timeout
    指定连接数据库的超时时间.
    spring.datasource.max-active
    指定连接池中最大的活跃连接数.
    spring.datasource.max-age
    指定连接池中连接的最大年龄
    spring.datasource.max-idle
    指定连接池最大的空闲连接数量.
    spring.datasource.max-lifetime
    指定连接池中连接的最大生存时间,毫秒单位.
    spring.datasource.max-open-prepared-statements
    指定最大的打开的prepared statements数量.
    spring.datasource.max-wait
    指定连接池等待连接返回的最大等待时间,毫秒单位.
    spring.datasource.maximum-pool-size
    指定连接池最大的连接数,包括使用中的和空闲的连接.
    spring.datasource.min-evictable-idle-time-millis
    指定一个空闲连接最少空闲多久后可被清除.
    spring.datasource.min-idle
    指定必须保持连接的最小值(For DBCP and Tomcat connection pools)
    spring.datasource.minimum-idle
    指定连接维护的最小空闲连接数,当使用HikariCP时指定.
    spring.datasource.name
    指定数据源名.
    spring.datasource.num-tests-per-eviction-run
    指定运行每个idle object evictor线程时的对象数量
    spring.datasource.password
    指定数据库密码.
    spring.datasource.platform
    指定schema要使用的Platform(schema-${platform}.sql),默认为: all
    spring.datasource.pool-name
    指定连接池名字.
    spring.datasource.pool-prepared-statements
    指定是否池化statements.
    spring.datasource.propagate-interrupt-state
    在等待连接时,如果线程被中断,是否传播中断状态.
    spring.datasource.read-only
    当使用Hikari connection pool时,是否标记数据源只读
    spring.datasource.register-mbeans
    指定Hikari connection pool是否注册JMX MBeans.
    spring.datasource.remove-abandoned
    指定当连接超过废弃超时时间时,是否立刻删除该连接.
    spring.datasource.remove-abandoned-timeout
    指定连接应该被废弃的时间.
    spring.datasource.rollback-on-return
    在归还连接时,是否回滚等待中的事务.
    spring.datasource.schema
    指定Schema (DDL)脚本.
    spring.datasource.separator
    指定初始化脚本的语句分隔符,默认: ;
    spring.datasource.sql-script-encoding
    指定SQL scripts编码.
    spring.datasource.suspect-timeout
    指定打印废弃连接前的超时时间.
    spring.datasource.test-on-borrow
    当从连接池借用连接时,是否测试该连接.
    spring.datasource.test-on-connect
    创建时,是否测试连接
    spring.datasource.test-on-return
    在连接归还到连接池时是否测试该连接.
    spring.datasource.test-while-idle
    当连接空闲时,是否执行连接测试.
    spring.datasource.time-between-eviction-runs-millis
    指定空闲连接检查、废弃连接清理、空闲连接池大小调整之间的操作时间间隔
    spring.datasource.transaction-isolation
    指定事务隔离级别,使用Hikari connection pool时指定
    spring.datasource.url
    指定JDBC URL.
    spring.datasource.use-disposable-connection-facade
    是否对连接进行包装,防止连接关闭之后被使用.
    spring.datasource.use-equals
    比较方法名时是否使用String.equals()替换==.
    spring.datasource.use-lock
    是否对连接操作加锁
    spring.datasource.username
    指定数据库名.
    spring.datasource.validation-interval
    指定多少ms执行一次连接校验.
    spring.datasource.validation-query
    指定获取连接时连接校验的sql查询语句.
    spring.datasource.validation-query-timeout
    指定连接校验查询的超时时间.
    spring.datasource.validation-timeout
    设定连接校验的超时时间,当使用Hikari connection pool时指定
    spring.datasource.validator-class-name
    用来测试查询的validator全限定名.
    spring.datasource.xa.data-source-class-name
    指定数据源的全限定名.
    spring.datasource.xa.properties
    指定传递给XA data source的属性
    

    DATASOURCE (PersistenceExceptionTranslationAutoConfiguration

    spring.dao.exceptiontranslation.enabled=true

    MONGODB (MongoProperties)

    spring.data.mongodb.host= # the db host
    spring.data.mongodb.port=27017 # the connection port (defaults to 27107)
    spring.data.mongodb.uri=mongodb://localhost/test # connection URL
    spring.data.mongodb.database=
    spring.data.mongodb.authentication-database=
    spring.data.mongodb.grid-fs-database=
    spring.data.mongodb.username=
    spring.data.mongodb.password=
    spring.data.mongodb.repositories.enabled=true # if spring data repository support is enabled

    JPA (JpaBaseConfiguration, HibernateJpaAutoConfiguration)

    spring.jpa.properties.*= # properties to set on the JPA connection
    spring.jpa.open-in-view=true
    spring.jpa.show-sql=true
    spring.jpa.database-platform=
    spring.jpa.database=
    spring.jpa.generate-ddl=false # ignored by Hibernate, might be useful for other vendors
    spring.jpa.hibernate.naming-strategy= # naming classname
    spring.jpa.hibernate.ddl-auto= # defaults to create-drop for embedded dbs
    spring.data.jpa.repositories.enabled=true # if spring data repository support is enabled

    JTA (JtaAutoConfiguration)

    spring.jta.log-dir= # transaction log dir
    spring.jta.*= # technology specific configuration

    SOLR (SolrProperties})

    spring.data.solr.host=http://127.0.0.1:8983/solr
    spring.data.solr.zk-host=
    spring.data.solr.repositories.enabled=true # if spring data repository support is enabled

    ELASTICSEARCH (ElasticsearchProperties})

    spring.data.elasticsearch.cluster-name= # The cluster name (defaults to elasticsearch)
    spring.data.elasticsearch.cluster-nodes= # The address(es) of the server node (comma-separated; if not specified starts a client node)
    spring.data.elasticsearch.repositories.enabled=true # if spring data repository support is enabled

    DATA RESET (RepositoryRestConfiguration})

    spring.data.rest.base-uri= # base URI against which the exporter should calculate its links

    FLYWAY (FlywayProperties)

    flyway.check-location=false # check that migration scripts location exists
    flyway.locations=classpath:db/migration # locations of migrations scripts
    flyway.schemas= # schemas to update
    flyway.init-version= 1 # version to start migration
    flyway.init-sqls= # SQL statements to execute to initialize a connection immediately after obtaining it
    flyway.sql-migration-prefix=V
    flyway.sql-migration-suffix=.sql
    flyway.enabled=true
    flyway.url= # JDBC url if you want Flyway to create its own DataSource
    flyway.user= # JDBC username if you want Flyway to create its own DataSource
    flyway.password= # JDBC password if you want Flyway to create its own DataSource

    LIQUIBASE (LiquibaseProperties)

    liquibase.change-log=classpath:/db/changelog/db.changelog-master.yaml
    liquibase.check-change-log-location=true # check the change log location exists
    liquibase.contexts= # runtime contexts to use
    liquibase.default-schema= # default database schema to use
    liquibase.drop-first=false
    liquibase.enabled=true
    liquibase.url= # specific JDBC url (if not set the default datasource is used)
    liquibase.user= # user name for liquibase.url
    liquibase.password= # password for liquibase.url

    JMX

    spring.jmx.enabled=true # Expose MBeans from Spring

    RABBIT (RabbitProperties)

    spring.rabbitmq.host= # connection host
    spring.rabbitmq.port= # connection port
    spring.rabbitmq.addresses= # connection addresses (e.g. myhost:9999,otherhost:1111)
    spring.rabbitmq.username= # login user
    spring.rabbitmq.password= # login password
    spring.rabbitmq.virtual-host=
    spring.rabbitmq.dynamic=

    REDIS (RedisProperties)

    spring.redis.database= # database name
    spring.redis.host=localhost # server host
    spring.redis.password= # server password
    spring.redis.port=6379 # connection port
    spring.redis.pool.max-idle=8 # pool settings ...
    spring.redis.pool.min-idle=0
    spring.redis.pool.max-active=8
    spring.redis.pool.max-wait=-1
    spring.redis.sentinel.master= # name of Redis server
    spring.redis.sentinel.nodes= # comma-separated list of host:port pairs
    Redis数据库索引(默认为0)

    • **spring.redis.database=0 **
      Redis服务器地址
    • spring.redis.host=192.168.0.58
      Redis服务器连接端口
    • **spring.redis.port=6379 **
    • Redis服务器连接密码(默认为空)
    • **spring.redis.password= **
      连接池最大连接数(使用负值表示没有限制)
    • **spring.redis.pool.max-active=8 **
      连接池最大阻塞等待时间(使用负值表示没有限制)
    • **spring.redis.pool.max-wait=-1 **
      连接池中的最大空闲连接
    • **spring.redis.pool.max-idle=8 **
      连接池中的最小空闲连接
    • **spring.redis.pool.min-idle=0 **
      连接超时时间(毫秒)
    • **spring.redis.timeout=0 **

    ACTIVEMQ (ActiveMQProperties)

    spring.activemq.broker-url=tcp://localhost:61616 # connection URL
    spring.activemq.user=
    spring.activemq.password=
    spring.activemq.in-memory=true # broker kind to create if no broker-url is specified
    spring.activemq.pooled=false

    HornetQ (HornetQProperties)

    spring.hornetq.mode= # connection mode (native, embedded)
    spring.hornetq.host=localhost # hornetQ host (native mode)
    spring.hornetq.port=5445 # hornetQ port (native mode)
    spring.hornetq.embedded.enabled=true # if the embedded server is enabled (needs hornetq-jms-server.jar)
    spring.hornetq.embedded.server-id= # auto-generated id of the embedded server (integer)
    spring.hornetq.embedded.persistent=false # message persistence
    spring.hornetq.embedded.data-directory= # location of data content (when persistence is enabled)
    spring.hornetq.embedded.queues= # comma-separated queues to create on startup
    spring.hornetq.embedded.topics= # comma-separated topics to create on startup
    spring.hornetq.embedded.cluster-password= # customer password (randomly generated by default)

    JMS (JmsProperties)

    spring.jms.jndi-name= # JNDI location of a JMS ConnectionFactory
    spring.jms.pub-sub-domain= # false for queue (default), true for topic

    Email (MailProperties)

    spring.mail.host=smtp.acme.org # mail server host
    spring.mail.port= # mail server port
    spring.mail.username=
    spring.mail.password=
    spring.mail.default-encoding=UTF-8 # encoding to use for MimeMessages
    spring.mail.properties.*= # properties to set on the JavaMail session

    SPRING BATCH (BatchDatabaseInitializer)

    spring.batch.job.names=job1,job2
    spring.batch.job.enabled=true
    spring.batch.initializer.enabled=true
    spring.batch.schema= # batch schema to load

    AOP

    spring.aop.auto=
    spring.aop.proxy-target-class=

    FILE ENCODING (FileEncodingApplicationListener)

    spring.mandatory-file-encoding=false

    SPRING SOCIAL (SocialWebAutoConfiguration)

    spring.social.auto-connection-views=true # Set to true for default connection views or false if you provide your own

    SPRING SOCIAL FACEBOOK (FacebookAutoConfiguration)

    spring.social.facebook.app-id= # your application's Facebook App ID
    spring.social.facebook.app-secret= # your application's Facebook App Secret

    SPRING SOCIAL LINKEDIN (LinkedInAutoConfiguration)

    spring.social.linkedin.app-id= # your application's LinkedIn App ID
    spring.social.linkedin.app-secret= # your application's LinkedIn App Secret

    SPRING SOCIAL TWITTER (TwitterAutoConfiguration)

    spring.social.twitter.app-id= # your application's Twitter App ID
    spring.social.twitter.app-secret= # your application's Twitter App Secret

    SPRING MOBILE SITE PREFERENCE (SitePreferenceAutoConfiguration)

    spring.mobile.sitepreference.enabled=true # enabled by default

    SPRING MOBILE DEVICE VIEWS (DeviceDelegatingViewResolverAutoConfiguration)

    spring.mobile.devicedelegatingviewresolver.enabled=true # disabled by default
    spring.mobile.devicedelegatingviewresolver.normal-prefix=
    spring.mobile.devicedelegatingviewresolver.normal-suffix=
    spring.mobile.devicedelegatingviewresolver.mobile-prefix=mobile/
    spring.mobile.devicedelegatingviewresolver.mobile-suffix=
    spring.mobile.devicedelegatingviewresolver.tablet-prefix=tablet/
    spring.mobile.devicedelegatingviewresolver.tablet-suffix=

    MANAGEMENT HTTP SERVER (ManagementServerProperties)

    management.port= # defaults to 'server.port'
    management.address= # bind to a specific NIC
    management.context-path= # default to '/'
    management.add-application-context-header= # default to true
    management.security.enabled=true # enable security
    management.security.role=ADMIN # role required to access the management endpoint
    management.security.sessions=stateless # session creating policy to use (always, never, if_required, stateless)

    PID FILE (ApplicationPidFileWriter)

    spring.pidfile= # Location of the PID file to write

    ENDPOINTS (AbstractEndpoint subclasses)

    endpoints.autoconfig.id=autoconfig
    endpoints.autoconfig.sensitive=true
    endpoints.autoconfig.enabled=true
    endpoints.beans.id=beans
    endpoints.beans.sensitive=true
    endpoints.beans.enabled=true
    endpoints.configprops.id=configprops
    endpoints.configprops.sensitive=true
    endpoints.configprops.enabled=true
    endpoints.configprops.keys-to-sanitize=password,secret,key # suffix or regex
    endpoints.dump.id=dump
    endpoints.dump.sensitive=true
    endpoints.dump.enabled=true
    endpoints.env.id=env
    endpoints.env.sensitive=true
    endpoints.env.enabled=true
    endpoints.env.keys-to-sanitize=password,secret,key # suffix or regex
    endpoints.health.id=health
    endpoints.health.sensitive=true
    endpoints.health.enabled=true
    endpoints.health.mapping.*= # mapping of health statuses to HttpStatus codes
    endpoints.health.time-to-live=1000
    endpoints.info.id=info
    endpoints.info.sensitive=false
    endpoints.info.enabled=true
    endpoints.mappings.enabled=true
    endpoints.mappings.id=mappings
    endpoints.mappings.sensitive=true
    endpoints.metrics.id=metrics
    endpoints.metrics.sensitive=true
    endpoints.metrics.enabled=true
    endpoints.shutdown.id=shutdown
    endpoints.shutdown.sensitive=true
    endpoints.shutdown.enabled=false
    endpoints.trace.id=trace
    endpoints.trace.sensitive=true
    endpoints.trace.enabled=true

    HEALTH INDICATORS (previously health.*)

    management.health.db.enabled=true
    management.health.diskspace.enabled=true
    management.health.mongo.enabled=true
    management.health.rabbit.enabled=true
    management.health.redis.enabled=true
    management.health.solr.enabled=true
    management.health.diskspace.path=.
    management.health.diskspace.threshold=10485760
    management.health.status.order=DOWN, OUT_OF_SERVICE, UNKNOWN, UP

    MVC ONLY ENDPOINTS

    endpoints.jolokia.path=jolokia
    endpoints.jolokia.sensitive=true
    endpoints.jolokia.enabled=true # when using Jolokia

    JMX ENDPOINT (EndpointMBeanExportProperties)

    endpoints.jmx.enabled=true
    endpoints.jmx.domain= # the JMX domain, defaults to 'org.springboot'
    endpoints.jmx.unique-names=false
    endpoints.jmx.static-names=

    JOLOKIA (JolokiaProperties)

    jolokia.config.*= # See Jolokia manual

    REMOTE SHELL

    shell.auth=simple # jaas, key, simple, spring
    shell.command-refresh-interval=-1
    shell.command-path-patterns= # classpath:/commands/, classpath:/crash/commands/**
    shell.config-path-patterns= # classpath:/crash/
    shell.disabled-commands=jpa,jdbc,jndi* # comma-separated list of commands to disable
    shell.disabled-plugins=false # don't expose plugins
    shell.ssh.enabled= # ssh settings ...
    shell.ssh.key-path=
    shell.ssh.port=
    shell.telnet.enabled= # telnet settings ...
    shell.telnet.port=
    shell.auth.jaas.domain= # authentication settings ...
    shell.auth.key.path=
    shell.auth.simple.user.name=
    shell.auth.simple.user.password=
    shell.auth.spring.roles=

    GIT INFO

    spring.git.properties= # resource ref to generated git info properties file

    解决SpringBoot连接池TOMCAT-JDBC(默认) DBCP或C3P0连接超时异常问题

    配置数据源连接池的时候如果没有配置连接检查或者超时回收,造成之后应用通过连接池getConnection时,都可能获取到这些不可用的连接。druid没有上述问题,因为默认有缺省值。

    隔多少时间回收废弃连接 一般比minEvictableIdleTimeMillis小
    spring.datasource.time-between-eviction-runs-millis=300000
    指定运行每个eviction线程时的对象数量
    spring.datasource.num-tests-per-eviction-run=3
    指定一个空闲连接最少空闲多久后可被清除.
    spring.datasource.min-evictable-idle-time-millis=3600000

    上面的配置是配置数据源回收连接,只要配置的回收时间小于mysql的超时时间就可以。

    spring.datasource.testOnBorrow=true
    spring.datasource.validationQuery=SELECT 1

    TestOnBorrow检测池里连接的可用性,假如连接池中的连接被数据库关闭了,应用通过连接池getConnection时会重新创建。validationQuery是检查时用的sql语句

    SpringBoot1.4.1 需要分别单独配置连接池的配置
    比如使用hikari连接池
    spring.datasource.type=com.zaxxer.hikari.HikariDataSource
    spring.datasource.hikari.minimum-idle=5

    源码地址

    https://github.com/je-ge/spring-boot



    作者:JeGe
    链接:https://www.jianshu.com/p/5a62b8dc02f3
    来源:简书
    简书著作权归作者所有,任何形式的转载都请联系作者获得授权并注明出处。
  • 相关阅读:
    unity HideInInspector与SerializeField
    Unity3D之游戏架构脚本该如何来写(转)
    写在创业公司工作后
    工作选择
    指针引用
    sqrt函数实现
    超平面
    【读书笔记】读《程序员面试宝典》
    【小白学游戏常用算法】一、随机迷宫算法
    【Cocos2d-x游戏开发】浅谈游戏中的坐标系
  • 原文地址:https://www.cnblogs.com/telwanggs/p/10779858.html
Copyright © 2011-2022 走看看