附錄

參考文件的這部分涵蓋適用於核心 Spring Framework 內多個模組的主題。

Spring 屬性

SpringProperties 是一個靜態持有器,用於控制 Spring Framework 某些底層層面。使用者可以透過 JVM 系統屬性或以程式化方式透過 SpringProperties.setProperty(String key, String value) 方法組態這些屬性。如果部署環境不允許自訂 JVM 系統屬性,則後者可能是必要的。或者,這些屬性可以在類別路徑根目錄的 spring.properties 檔案中組態 — 例如,部署在應用程式的 JAR 檔案中。

下表列出目前所有支援的 Spring 屬性。

表 1. 支援的 Spring 屬性
名稱 描述

spring.aop.ajc.ignore

指示 Spring 忽略 ajc 編譯的 Aspect 以進行 Spring AOP 代理,在同時啟用編織和 AspectJ 自動代理的場景中恢復傳統的 Spring 行為。請參閱 AbstractAspectJAdvisorFactory 以取得詳細資訊。

spring.aot.enabled

指示應用程式應使用 AOT 產生的 Artifact 執行。請參閱 預先編譯最佳化AotDetector 以取得詳細資訊。

spring.beaninfo.ignore

指示 Spring 在呼叫 JavaBeans Introspector 時使用 Introspector.IGNORE_ALL_BEANINFO 模式。請參閱 StandardBeanInfoFactory 以取得詳細資訊。

spring.cache.reactivestreams.ignore

指示 Spring 的快取基礎架構忽略 Reactive Streams 的存在,特別是在 @Cacheable 方法傳回類型宣告中 Reactor 的 Mono/Flux。請參閱 CacheAspectSupport 以取得詳細資訊。

spring.classformat.ignore

指示 Spring 在類別路徑掃描期間忽略類別格式例外,特別是針對不支援的類別檔案版本。請參閱 ClassPathScanningCandidateComponentProvider 以取得詳細資訊。

spring.context.checkpoint

指定通用 Context 檢查點的屬性。請參閱 啟動時自動檢查點/還原DefaultLifecycleProcessor 以取得詳細資訊。

spring.context.exit

用於在 Context 達到特定階段時終止 JVM 的屬性。請參閱 啟動時自動檢查點/還原DefaultLifecycleProcessor 以取得詳細資訊。

spring.context.expression.maxLength

用於 XML Bean 定義、@Value 等的 Spring 運算式語言 運算式的最大長度。

spring.expression.compiler.mode

編譯 Spring 運算式語言 的運算式時要使用的模式。

spring.getenv.ignore

指示 Spring 在 Spring Environment 屬性(例如,組態 String 中的佔位符)無法解析時,忽略作業系統環境變數。請參閱 AbstractEnvironment 以取得詳細資訊。

spring.jdbc.getParameterType.ignore

指示 Spring 完全忽略 java.sql.ParameterMetaData.getParameterType。請參閱 物件列表的批次操作 中的註解。

spring.jndi.ignore

指示 Spring 忽略預設的 JNDI 環境,作為一種最佳化,適用於從一開始就永遠找不到此類 JNDI 後備搜尋的情況,從而避免重複的 JNDI 查找開銷。請參閱 JndiLocatorDelegate 以取得詳細資訊。

spring.objenesis.ignore

指示 Spring 忽略 Objenesis,甚至不嘗試使用它。請參閱 SpringObjenesis 以取得詳細資訊。

spring.test.aot.processing.failOnError

一個布林旗標,用於控制在Spring TestContext Framework 中的 AOT 處理期間遇到的錯誤是否應導致例外,從而導致整體程序失敗。請參閱 Tests 的預先編譯支援

spring.test.constructor.autowire.mode

如果測試類別上不存在 @TestConstructor,則要使用的預設測試建構子自動裝配模式。請參閱 變更預設測試建構子自動裝配模式

spring.test.context.cache.maxSize

Spring TestContext Framework 中 Context 快取的最大大小。請參閱 Context 快取

spring.test.context.failure.threshold

Spring TestContext Framework 中嘗試載入 ApplicationContext 時遇到的錯誤的失敗閾值。請參閱 Context 失敗閾值

spring.test.enclosing.configuration

如果測試類別上不存在 @NestedTestConfiguration,則要使用的預設封閉組態繼承模式。請參閱 變更預設封閉組態繼承模式