spring中applicationContext.xml的載入過程
web容器在啟動時,會執行事先配置的監聽器ContextLoaderListener裡的contextInitialized方法,該方法再去呼叫了initWebApplicationContext方法。
該方法載入了ContextLoader類,在ContextLoader中有一塊靜態程式碼塊,
該程式碼塊中會載入一個ContextLoader.properties屬性檔案,屬性檔案程式碼如下,指向了一個XmlWebApplicationContext類,
該類指定了web容器預設載入的spring核心配置檔名稱和路徑為 /WEB-INF/applicationContext.xml 。所以我們預設會把這個配置檔案定義為applicationContext.xml,路徑就放在WEB-INF下面。
所以,我們可以更改這個核心配置檔案的名稱和路徑,修改後,只需要在web.xml檔案裡增加如下配置:
這是我本地核心配置檔案的名稱applicationContext11.xml。如果不加這個配置,容器會報錯。
相關推薦
spring中applicationContext.xml的載入過程
web容器在啟動時,會執行事先配置的監聽器ContextLoaderListener裡的contextInitialized方法,該方法再去呼叫了initWebApplicationContext方法。 該方法載入了ContextLoader類,在ContextLo
spring中applicationContext.xml在web.xml中的配置路徑說明
在web專案裡使用了spring框架,我們經常需要在web容器啟動時自動初始化spring容器。要想實現這一功能,就需要在web.xml中增加一個上下文引數,指定spring的配置檔案applicationContext.xml。 <context-param>
Spring中applicationContext.xml配置檔案中資料庫資料來源配置
<!-- 標頭檔案,主要注意一下編碼 --> <?xmlversion="1.0"encoding="UTF-8"?> <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN""http://www.springframework
Web程式的啟動(一):在web.xml中的配置spring中applicationContext.xml路徑說明
<context-param> <param-name>contextConfigLocation</param-name> <param-value>WEB-INF/applicationContext*.xml<
Spring 專案中applicationContext.xml模板
<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2
Spring原始碼解析-applicationContext.xml載入和bean的註冊
Spring原始碼解析-applicationContext.xml載入和bean的註冊 萬事開頭難,就要從頭開始 Spring初始化 Spring是如何找到applicationContext.xml檔案 將xml檔
spring mvc中applicationContext.xml與spring-mvc.xml的關係
前言 本文參考了: 值得注意的是,【【Spring】淺談ContextLoaderListener及其上下文與DispatcherServlet的區別】中闡述了contextLoaderListener和dispatcherServlet的關係, co
spring+hibernate中applicationContext.xml詳解
對裡面的一些概念還不熟悉,一個字"暈"啊,在網上搜搜資料,解釋一下applicationcontext.xml 我們以專案中的訂單Order為例簡要說明一下Spring與Hibernate的整合。關於如何使用Hibernate來對資料庫表做對映,我們在前面已經做了介紹,
Spring中ApplicationContext載入機制和配置初始化
Spring中ApplicationContext載入機制。 載入器目前有兩種選擇:ContextLoaderListener和ContextLoaderServlet。 這兩者在功能上完全等同,只是一個是基於Servlet2.3版本中新引入
spring中applicationContex.xml文件
span -name start resource oca default spa 文件 mapping <mvc:resources mapping="/js/**" location="/WEB_INF/js"/>主要用於靜態資源的訪問. 使用springM
關於spring的applicationContext.xml配置文件的ref和value之自我想法
定時 框架 ots 類型轉換 job ica ont spring配置 str 今天在做SSH的一個項目的時候,因為需要定時操作,所以就再sping裏面加入了一個quartz的小定時框架,結果在運行時候,發生了一個小bug. Caused by: org.sprin
第九篇:Spring的applicationContext.xml配置總結
在前面的一篇日誌中,記錄了web.xml配置啟動的順序,web啟動到監聽器ContextLoaderListener時,開始載入spring的配置檔案applicationContext.xml(通常就叫這個名字),在查詢大量資料之後決心將該檔案詳細的配置說明和講解記錄下來,以供查閱,加深原理的理解。&nbs
Spring --15.Spring中基於xml的宣告事務控制
開發環境: jdk1.8 Idea 2017 :Maven工程、引入父工程 Tomcat:apache-tomcat-8 Spring:5.0.7 一、事務控制 1、概述 事務的概念: 事務是邏輯上一組操作、組成這組操作各個邏輯單元、要麼一起成功、要麼一起失敗。 事
Spring的applicationContext.xml配置檔案如何查詢
目錄 一、文章前言 Spring需要載入配置檔案applicationContext.xml,那麼自帶的jar包又沒有,該如何查詢;在網上找又怕找的不對,那麼其實很簡單,當我們在jar包找不
在eclipse中報applicationContext.xml載入失敗
最有可能的是,資料庫連線資訊的問題 例如錯誤配置 <bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource"> <property name="d
Spring中關於xml匯入其他xml問題
如果我們在spring框架中配置了多個xml檔案,我們可以在讀取配置檔案的時候把這些xml檔案一下全都讀取,也可以只讀一個總的xml檔案,在這個總的xml檔案中把其他的xml全都都匯入進來。 例如: 有一個名字叫student.xml的配置檔案和teacher.xml的配置檔案把他們匯入到
Spring中的資源載入
大家也都知道JDK的類載入器:BootStrap ClassLoader、ExtenSion ClassLoader、Application ClassLoader;也使用了雙親委派模型,主要是為了防止程式碼注入; 但是我一直在想那Spring 這麼牛逼的框架到底有沒有自定義的類載入器呢? S
Spring --15.Spring中基於xml的宣告式事務控制
開發環境: jdk1.8 Idea 2017 :Maven工程、引入父工程 Tomcat:apache-tomcat-8 Spring:5.0.7 一、事務控制 1、概述 事務的概念:事務是邏輯上一組操作、組成這組操作各個邏輯單元、要麼一起成功、要麼一起失敗。
Spring中配置Quartz的過程;Spring與Quartz的相容問題
1. 根據spring和Quratz的版本不同,觸發器的方法可能不同,有org.springframework.scheduling.quartz.SimpleTriggerFactoryBean和org.springframework.scheduling.quar
ssm框架中,web專案中applicationContext.xml及相關配置檔案解析
一、概述 applicationContext.xml,即Spring上下文配置檔案,用於完成Spring和MyBatis的整合。主要配置bean自動掃描、依賴注入、資料庫、事務等。如下 <?xml version="1.0" encoding="UTF-8"?> &l