資源載入說明

2021-09-07 13:49:11 字數 584 閱讀 6224

1 classpath: 和 classpath:/ 是等價的,都是相對於類路徑的根路徑。

2 classpath: 比如,com.smart,只會在第乙個載入 com.smart 包的類路徑下查詢。而 "classpath*:" 會掃瞄所有這些 jar 包及類路徑下出現的 com.smart 類路徑。

3 對於分模組打包的應用,classpath*: 可以載入多個配置檔案。假設名為 samrt 的應用,包含 3 個模組,乙個模組乙個配置檔案。分別是 module1.xml, module2.xml, module3.xml

都放到了 com.smart 目錄下,每個模組單獨打包成 jar 包。使用 「classpath*:/com/smart/module*.xml」 可以成功載入這3個配置檔案,而使用「classpath:/com/smart/module*.xml」 只會載入乙個模組的

配置檔案。

4 ant 風格的資源位址支援 3 種匹配符

5 一些例子

AssetBundle資源載入

一 第一種載入方式本地相對路徑資源載入 assetbundle ab assetbundle.loadfromfile assetbundle sphere.unity3d 本地載入相對路徑載入 載入ab包 gameobject cube ab.loadasset sphere 獲取ab包 inst...

資源預載入

提到前端效能優化時,我們首先會聯想到檔案的合併 壓縮,檔案快取和開啟伺服器端的gzip壓縮等,這使得頁面載入更快,使用者可以盡快使用我們的 web 應用來達到他們的目標。資源預載入是另乙個效能優化技術,我們可以使用該技術來預先告知瀏覽器某些資源可能在將來會被使用到。引用 patrick hamann...

Spring Resource載入資源

在spring內部,針對於資源檔案有乙個統一的介面resource表示。其主要實現類有classpathresource filesystemresource urlresource bytearrayresource servletcontextresource和inputstreamresour...