日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 前端技术 > javascript >内容正文

javascript

Spring Boot application.properties 常用配置

發布時間:2025/3/12 javascript 34 豆豆
生活随笔 收集整理的這篇文章主要介紹了 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

是使用
這種形式,還是
這種展開模式,默認為: 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

如果感覺不錯的話請點贊喲!!!

總結

以上是生活随笔為你收集整理的Spring Boot application.properties 常用配置的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。