1. Spring 基本屬性
1) 應用配置 (SpringApplication)
# 運行時顯示的橫幅(Banner)
spring.banner.charset=UTF-8 # banner 文件編碼
spring.banner.location=banner.txt # banner 文件位置
spring.main.banner-mode=console # 橫幅(banner)的模式,可選值:off、console、log
spring.config.name=application # 配置文件名
spring.config.location= # 配置文件位置
spring.aop.auto=true # AOP 切面,添加 @EnableAspectJAutoProxy
spring.aop.proxy-target-class=false # 是否要創建基於子類(CGLIB)的代理(true),而不是基於標准的基於Java接口的代理(false)
spring.autoconfigure.exclude= # 自動配置類排除
spring.beaninfo.ignore= true # 跳過搜索BeanInfo類
2) Spring 緩存配置
spring.cache.cache-names= # 由底層緩存管理器支持的要創建的緩存名稱的逗號分隔列表
spring.cache.ehcache.config= # 用於初始化 EhCache 的配置文件的位置
spring.cache.guava.spec= # 用於創建緩存的規范,檢查 CacheBuilderSpec 有關規格格式的更多細節
spring.cache.hazelcast.config= # 用於初始化 Hazelcast的 配置文件的位置
spring.cache.infinispan.config= # 用於初始化 Infinispan 的配置文件的位置
spring.cache.jcache.config= # 用於初始化緩存管理器的配置文件的位置
spring.cache.jcache.provider= # 用於檢索符合 JSR-107 的緩存管理器的 CachingProvider 實現的完全限定名稱
spring.cache.type= # 緩存類型,默認情況下根據環境自動檢測
3) Redis 配置 (RedisProperties)
spring.redis.database=0 # 連接工廠使用的數據庫索引
spring.redis.host=localhost # Redis 服務器主機
spring.redis.port=6379 # Redis 服務器端口
spring.redis.password= # 登錄 Redis 服務器的密碼
spring.redis.timeout=0 # 連接超時(毫秒)
spring.redis.pool.max-active=8 # 給定時間池可以分配的最大連接數,使用負值為無限制
spring.redis.pool.max-idle=8 # 池中 “空閑” 連接的最大數量,使用負值來表示無限數量的空閑連接
spring.redis.pool.max-wait=-1 # 連接分配在池耗盡之前在拋出異常之前應阻止的最大時間量(以毫秒為單位),使用負值無限期地阻止
spring.redis.pool.min-idle=0 # 定義池中維護的最小空閑連接數,此設置只有在正值時才有效果
spring.redis.sentinel.master=
spring.redis.sentinel.nodes=
4) Email 配置 (MailProperties)
spring.mail.jndi-name= # 會話JNDI名稱。設置時,優先於其他郵件設置
spring.mail.protocol=smtp # SMTP服務器使用的協議
spring.mail.host= # SMTP服務器主機,例如 'smtp.example.com'
spring.mail.port= # SMTP服務器端口
spring.mail.username= # 登錄SMTP服務器的用戶
spring.mail.password= # 登錄SMTP服務器的密碼
spring.mail.default-encoding=UTF-8 # 默認 MimeMessage 編碼
spring.mail.properties.*= # 其他 JavaMail 會話屬性
spring.mail.test-connection=false # 測試郵件服務器在啟動時可用
5) 國際化 (MessageSourceAutoConfiguration)
spring.messages.basename=messages # 以逗號分隔的基礎名稱列表,每個都在ResourceBundle約定之后
spring.messages.cache-seconds=-1 # 加載的資源束文件緩存到期,以秒為單位。 設置為-1時,軟件包將永久緩存
spring.messages.encoding=UTF-8 # 消息編碼
spring.messages.fallback-to-system-locale=true # 設置是否返回到系統區域設置,如果沒有找到特定語言環境的文件
6) 日志配置 (LOGGING)
logging.config= # 日志配置文件的位置,例如 Logback 的 'classpath:logback.xml'
logging.file= # 日志文件名,例如 'myapp.log'
logging.level.*= # 日志級別嚴重性映射,例如 'logging.level.org.springframework=DEBUG'
logging.path= # 日志文件的位置,例如 '/var/log'
logging.pattern.file= # 用於輸出到文件的 Appender 模式,只支持默認的 logback 設置
logging.pattern.level= # 日志級別的Appender模式(默認%5p),只支持默認的logback設置
logging.pattern.console= # 用於輸出到控制台的 Appender 模式,只支持默認的logback設置
logging.register-shutdown-hook=false # 注冊日志記錄系統的初始化掛鈎
logging.exception-conversion-word= # %wEx#記錄異常時使用的轉換字
2. Web 屬性
1)嵌入式 Web 容器配置
server.display-name=application # 顯示應用程序的名稱
server.address=localhost # 服務器應綁定到的網絡地址
server.port=8080 # 服務器HTTP端口
server.compression.enabled=false # 是否啟用響應壓縮
server.compression.mime-types= # MIME類型的逗號分隔列表,例如 'text/html,application/json'
server.compression.min-response-size= # 執行壓縮所需的最小響應大小。 例如2048
server.compression.excluded-user-agents= # 從壓縮中排除的用戶代理列表
server.error.path=/error # 錯誤控制器的路徑
server.error.whitelabel.enabled=true # 啟動瀏覽器中出現服務器錯誤時顯示的默認錯誤頁面
server.error.include-stacktrace=never # 何時包含 “stacktrace” 屬性
server.context-path= # 應用程序的上下文路徑
server.context-parameters.*= # Servlet上下文初始化參數。 例如 'server.context-parameters.a= test'
server.servlet-path=/ # 主調度程序servlet的路徑
server.jsp-servlet.class-name=org.apache.jasper.servlet.JspServlet # JSP servlet的類名
server.jsp-servlet.registered=true # JSP servlet 是否被注冊
server.jsp-servlet.init-parameters.*= # Init 參數用於配置 JSP servlet
# Session 配置
server.session.timeout=60 # 會話超時(秒)
server.session.store-dir= # 用於存儲會話數據的目錄
server.session.persistent=false # 重啟之間持續會話數據
server.session.tracking-modes= # 會話跟蹤模式(以下一個或多個:“cookie”,“url”,“ssl”)
server.session.cookie.name= # 會話cookie名稱
server.session.cookie.path= # 會話cookie的路徑
server.session.cookie.domain= # 會話cookie的域
server.session.cookie.comment= # 會話cookie的注釋
server.session.cookie.http-only= # “HttpOnly” 標志為會話 cookie
server.session.cookie.max-age= # 會話cookie的最大時長(以秒為單位)
server.session.cookie.secure= # 會話cookie的 “安全” 標志
# Tomcat 配置
server.tomcat.basedir= # Tomcat基本目錄。如果未指定,將使用臨時目錄
server.tomcat.uri-encoding=UTF-8 # 用於解碼URI的字符編碼
server.tomcat.max-threads=0 # 最大工作線程數
server.tomcat.background-processor-delay=30 # 在調用 backgroundProcess 方法之間延遲秒
server.tomcat.internal-proxies= # 正則表達式匹配可信IP地址
server.tomcat.max-http-header-size=0 # HTTP消息頭的最大大小(以字節為單位
server.tomcat.remote-ip-header= # 提取遠程ip的HTTP頭的名稱。 例如`X-FORWARDED-FOR`
server.tomcat.port-header=X-Forwarded-Port # 用於覆蓋原始端口值的HTTP頭的名稱。
server.tomcat.protocol-header= # 頭文件,保存傳入協議,通常命名為“X-Forwarded-Proto”
server.tomcat.protocol-header-https-value=https # 表示傳入請求使用SSL的協議頭的值
server.tomcat.accesslog.enabled=false # 啟用訪問日志
server.tomcat.accesslog.directory= # 創建日志文件的目錄。可以相對於tomcat base dir或absolute。
server.tomcat.accesslog.pattern=common # 訪問日志的格式化模式
server.tomcat.accesslog.prefix=access_log # 日志文件名前綴
server.tomcat.accesslog.suffix=.log # 日志文件名后綴
# SSL 配置
server.ssl.ciphers= # 支持SSL密碼
server.ssl.client-auth= # 客戶端認證是否需要(“want”)或需要(“need”)。 需要信任存儲。
server.ssl.enabled=
server.ssl.protocol=
server.ssl.key-alias=
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.trust-store=
server.ssl.trust-store-password=
server.ssl.trust-store-provider=
server.ssl.trust-store-type=
2) HTTP 配置
spring.http.encoding.enabled=true # 啟用http編碼支持
spring.http.encoding.charset=UTF-8 # HTTP請求和響應的字符集。 如果未明確設置,則添加到“Content-Type” 頭
spring.http.encoding.force=true # 將編碼強制到HTTP請求和響應上配置的字符集
spring.http.converters.preferred-json-mapper=jackson # HTTP 消息轉換,首選JSON映射程序用於HTTP消息轉換,Gson,Jackson
3) 文件上傳屬性
multipart.enabled=true # 啟用對文件上傳的支持
multipart.location= # 上傳文件的位置
multipart.max-file-size=2Mb # 最大文件大小,使用后綴 MB 或 KB
multipart.max-request-size=10Mb # 最大請求大小,使用后綴 MB 或 KB
multipart.file-size-threshold=0 # 將文件寫入磁盤后的閾值,使用后綴 MB 或 KB
4) Spring MVC 配置
spring.mvc.view.prefix= # Spring MVC視圖前綴
spring.mvc.view.suffix= # Spring MVC視圖后綴
spring.mvc.date-format= # 要使用的日期格式。 例如 'dd/MM/yyyy'
spring.mvc.locale= # 要使用的區域設置
spring.mvc.async.request-timeout= # 異步請求處理超時之前的時間量(以毫秒為單位)
spring.mvc.dispatch-trace-request=false # 發送 TRACE 請求到 FrameworkServlet doService 方法
spring.mvc.dispatch-options-request=false # 發送 OPTIONS 請求到 FrameworkServlet doService 方法
spring.mvc.favicon.enabled=true # 啟用 favicon.ico 的解析
spring.mvc.media-types.*= # 將文件擴展名映射到內容協商的媒體類型
spring.mvc.message-codes-resolver-format= # 消息代碼格式策略。例如 'PREFIX_ERROR_CODE'
spring.mvc.static-path-pattern=/** # 用於靜態資源的路徑模式
spring.mvc.ignore-default-model-on-redirect= true # 如果在重定向方案期間應該忽略 “默認” 模型的內容
spring.mvc.throw-exception-if-no-handler-found=false # 如果沒有發現處理程序來處理請求,則應拋出 'NoHandlerFoundException'
5) 資源處理(ResourceProperties)
spring.resources.add-mappings=true # 啟用默認資源處理
spring.resources.cache-period= # 由資源處理程序提供的資源的緩存期,以秒為單位
spring.resources.chain.cache=true # 在資源鏈中啟用緩存
spring.resources.chain.enabled= # 啟用Spring資源處理鏈。默認情況下禁用,除非啟用了至少一個策略
spring.resources.chain.html-application-cache=false # 啟用HTML5應用程序緩存清單重寫
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/,classpath:/resources/,classpath:/static/,classpath:/public/ # 靜態資源的位置
6) Thymeleaf 模板引擎配置
spring.thymeleaf.cache=true # 啟用模板緩存
spring.thymeleaf.check-template-location=true # 檢查模板位置是否存在
spring.thymeleaf.content-type=text/html # Content-Type值
spring.thymeleaf.enabled=true # 啟用 MVC Thymeleaf 視圖分辨率
spring.thymeleaf.encoding=UTF-8 # 模板編碼
spring.thymeleaf.excluded-view-names= # 應該從解決方案中排除的視圖名稱的逗號分隔列表
spring.thymeleaf.mode=HTML5 # 應用於模板的模板模式,參見 StandardTemplateModeHandlers
spring.thymeleaf.prefix=classpath:/templates/ # 在構建URL時預先查看名稱的前綴
spring.thymeleaf.suffix=.html # 構建URL時附加查看名稱的后綴
spring.thymeleaf.template-resolver-order= # 鏈中模板解析器的順序
spring.thymeleaf.view-names= # 可以解析的視圖名稱的逗號分隔列表
3. Data 屬性
1) 數據源(數據庫)配置 (DataSourceAutoConfiguration & DataSourceProperties)
spring.datasource.driver-class-name= # JDBC驅動程序的完全限定名稱。默認情況下,根據URL自動檢測。
spring.datasource.type= # 要使用的連接池實現的完全限定名稱。默認情況下,它是從類路徑自動檢測的
spring.datasource.url= # 數據庫的 JDBC url
spring.datasource.name= # 數據庫的名稱
spring.datasource.username= # 數據庫用戶名
spring.datasource.password= # 數據庫的密碼
spring.datasource.continue-on-error=false #初始化數據庫時發生錯誤時不要停止
spring.datasource.data= # Data(DML)腳本資源引用
spring.datasource.initialize=true # 使用'data.sql'填充數據庫
spring.datasource.jmx-enabled=false # 啟用JMX支持(如果由底層池提供)
spring.datasource.jndi-name= # 數據源的JNDI位置。設置時,類,網址,用戶名和密碼將被忽略
spring.datasource.max-active= # 例如100
spring.datasource.max-idle= # 例如8
spring.datasource.max-wait=
spring.datasource.min-evictable=
spring.datasource.min-idle=8
spring.datasource.platform=all # 在資源模式(schema - $ {platform} .sql)中使用的平台
spring.datasource.schema= # Schema(DDL)腳本資源引用
spring.datasource.separator=; # 語句分隔符在SQL初始化腳本中
spring.datasource.sql-script-encoding= # SQL腳本編碼。
spring.datasource.test-on-borrow=false
spring.datasource.test-on-return=false
spring.datasource.test-while-idle=
spring.datasource.time-between-eviction-runs-millis=1
spring.datasource.validation-query=
2) JPA 配置 (JpaBaseConfiguration, HibernateJpaAutoConfiguration)
spring.jpa.database= # 目標數據庫進行操作,默認情況下自動檢測。可以使用 “databasePlatform” 屬性設置。
spring.jpa.database-platform= # 要運行的目標數據庫的名稱,默認情況下自動檢測。可以使用 “數據庫” 枚舉來設置。
spring.jpa.generate-ddl=false # 啟動時初始化模式。
spring.jpa.hibernate.ddl-auto= # DDL模式。這實際上是 “hibernate.hbm2ddl.auto” 屬性的快捷方式。使用嵌入式數據庫時默認為 “創建刪除”,否則為 “否”。
spring.jpa.hibernate.naming-strategy= # 命名策略完全限定名。
spring.jpa.open-in-view=true # 注冊 OpenEntityManagerInViewInterceptor,將 JPA EntityManager 綁定到線程以進行請求的整個處理。
spring.jpa.properties.*= # 在JPA提供程序上設置的其他本機屬性
spring.jpa.show-sql=false # 啟用SQL語句的日志記錄
spring.data.jpa.repositories.enabled=true # 啟用JPA存儲庫
3) DATA REST (RepositoryRestProperties)
spring.data.rest.base-path= # 由Spring Data REST用於公開存儲庫資源的基本路徑
spring.data.rest.default-page-size= # 頁面的默認大小
spring.data.rest.enable-enum-translation= # 通過Spring Data REST默認資源包啟用枚舉值轉換
spring.data.rest.limit-param-name= # 指示一次返回多少結果的URL查詢字符串參數的名稱
spring.data.rest.max-page-size= # 最大頁面大小
spring.data.rest.page-param-name= # 指示要返回的頁面的URL查詢字符串參數的名稱
spring.data.rest.return-body-on-create= # 創建一個實體后返回響應體
spring.data.rest.return-body-on-update= # 更新實體后返回響應體
spring.data.rest.sort-param-name= # 指示排序結果的方向的URL查詢字符串參數的名稱
4) ELASTICSEARCH (ElasticsearchProperties)
spring.data.elasticsearch.cluster-name=elasticsearch # 彈性搜索集群名稱
spring.data.elasticsearch.cluster-nodes= # 集群節點地址的逗號分隔列表。如果未指定,則啟動客戶端節點
spring.data.elasticsearch.properties.*= # 用於配置客戶端的其他屬性
spring.data.elasticsearch.repositories.enabled=true # 啟用 Elasticsearch 存儲庫
5) MONGODB (MongoProperties)
spring.data.mongodb.uri=mongodb://localhost/test # Mongo數據庫URI。 設置時,主機和端口將被忽略
spring.data.mongodb.host=localhost # Mongo服務器主機
spring.data.mongodb.port=27017 # Mongo服務器端口
spring.data.mongodb.database=test # 數據庫名稱
spring.data.mongodb.username= # 登錄mongo服務器的用戶
spring.data.mongodb.password= # 登錄mongo服務器的密碼
spring.data.mongodb.authentication-database= # 驗證數據庫名稱
spring.data.mongodb.grid-fs-database= # GridFS數據庫名稱
spring.data.mongodb.repositories.enabled = true # 啟用Mongo存儲庫
spring.data.mongodb.field-naming-strategy= # 要使用的FieldNamingStrategy的完全限定名稱
4. 安全屬性
1) SECURITY(SecurityProperties)
security.basic.authorize-mode = role # 應用安全授權模式。
security.basic.enabled = true # 啟用基本身份驗證。
security.basic.path = / ** # 安全路徑的逗號分隔列表。
security.basic.realm = Spring # HTTP基本的領域名稱。
security.enable-csrf = false # 啟用跨站點請求偽造支持。
security.filter-order = 0 # 安全過濾器連鎖訂單。
security.headers.cache = true # 啟用緩存控制HTTP頭。
security.headers.content-type = true # 啟用“X-Content-Type-Options”頭。
security.headers.frame = true # 啟用“X-Frame-Options”標題。
security.headers.hsts = # HTTP嚴格傳輸安全(HSTS)模式(無,域,全部)。
security.headers.xss = true # 啟用跨站點腳本(XSS)保護。
security.ignored = # 從默認安全路徑中排除的路徑的逗號分隔列表。
security.require-ssl = false # 為所有請求啟用安全通道。
security.sessions = stateless # 會話創建策略(永遠不會,if_required,無狀態)。
security.user.name = user # 默認用戶名。
security.user.password = # 默認用戶名的密碼。默認情況下,啟動時會記錄隨機密碼。
security.user.role = USER # 為默認用戶名授予角色。
2) SECURITY OAUTH2 CLIENT(OAuth2ClientProperties)
security.oauth2.client.client-id = # OAuth2客戶端ID。
security.oauth2.client.client-secret = # OAuth2客戶機密碼。默認生成隨機密碼
3) SECURITY OAUTH2 RESOURCES(ResourceServerProperties)
security.oauth2.resource.id = # 資源的標識符。
security.oauth2.resource.jwt.key-uri = # JWT令牌的URI。如果值不可用並且密鑰是公共的,可以設置。
security.oauth2.resource.jwt.key-value = # JWT令牌的驗證密鑰。可以是對稱秘密或PEM編碼的RSA公鑰。
security.oauth2.resource.prefer-token-info = true # 使用令牌信息,可以設置為false以使用用戶信息。
security.oauth2.resource.service-id = resource #
security.oauth2.resource.token-info-uri = # 令牌解碼端點的URI。
security.oauth2.resource.token-type = # 使用userInfoUri時發送的令牌類型。
security.oauth2.resource.user-info-uri = # 用戶端點的URI。
4) SECURITY OAUTH2 SSO(OAuth2SsoProperties)
security.oauth2.sso.filter-order = # 如果不提供顯式的WebSecurityConfigurerAdapter,則應用過濾器順序
security.oauth2.sso.login-path = /login # 登錄頁面的路徑,即觸發重定向到OAuth2授權服務器的路徑