spring載入多個配置檔案

2021-04-23 03:27:46 字數 463 閱讀 1071

載入器目前有兩種選擇:contextloaderlistener和contextloaderservlet。

這兩者在功能上完全等同,只是乙個是基於servlet2.3版本中新引入的listener介面實現,而另乙個基於servlet介面實現。開發中可根據目標web容器的實際情況進行選擇。

配置非常簡單,在web.xml中增加:

org.springframework.web.context.contextloaderlistener

或: context

org.springframework.web.context.contextloaderservlet 1

檔案

eg2.

string locations = ;

配置檔案

eg3.檔案

eg1.  

Spring載入多個配置檔案

關於spring載入多個配置檔案的方式 1.在web.xml檔案中註冊 org.springframework.web.context.contextloaderlistener 在乙個配置檔案中的bean想要引用另乙個檔案中的bean,可以使用這樣拿到。注意是bean 而不是local 如果是使用...

Spring 怎樣載入多個bean 配置檔案

2 web 應用啟動時載入多個配置檔案 參看5.12.3 節所述,通過contextloaderlistener 也可載入多個配置檔案,可利用 337輕量級j2ee 企業應用實戰一一 struts spring hibernate 整合開發 元素來指定多個配置檔案位置,其配置如下 contextco...

spring配置檔案載入

spring配置檔案的裝載在web.xml中配置 此引數用於後面的spring context loader contextconfiglocation org.springframework.web.context.contextloaderlistener 說明 contextconfigloc...