沙漠中的魚

          欲上天堂,先下地獄
          posts - 0, comments - 56, trackbacks - 0, articles - 119
            BlogJava :: 首頁 ::  :: 聯系 :: 聚合  :: 管理

          關于多個ApplicationContext文件加載

          Posted on 2008-02-28 23:12 沙漠中的魚 閱讀(1610) 評論(0)  編輯  收藏 所屬分類: 開源框架

          在業務項目開發中,數據表比較多,把所有的配置信息放在一個文件就會顯得文件過于龐大,不好管理和維護,所以就應當為每個應當模塊創建一個ApplicationContext文件,web.xml文件中

          Spring官方提供了一種加載多個ApplicationContext.Xml文件的方法

          http://struts.apache.org/ 2.0.11/docs/spring-plugin.html

          More applicationContext configuration files needed?

          Since the Spring integration uses a standard Listener, it can be configured to support configuration files other than applicationContext.xml. Adding the following to your web.xml will cause Spring's ApplicationContext to be inititalized from all files matching the given pattern:

          <!-- Context Configuration locations for Spring XML files -->

          <context-param>

          <param-name>contextConfigLocation</param-name> <param-value>/WEB-INF/applicationContext-*.xml,classpath*:applicationContext-*.xml</param-value>

          </context-param>

          我按照官方提供的示例,進行配置、編譯,但是會出不能正常啟動程序,找了很久也只能判斷是這兒出現了問題,但是不知道是什么原因,只好跟據自己的判斷重新寫了另一種加載方式

          <context-param>

              <param-name>contextConfigLocation</param-name>

          <param-value>/WEB-INF/applicationContext-*.xml, classpath:applicationContext_*.xml </param-value>

          </context-param>

          我現在就搞不懂了,為什么官方提供的示例不能用,有哪位能介訴我嗎

           

          還有另一種可能編譯不能正常起動的原因,就是我在配置文件提供的路徑,如果路徑中找不不到任何相關的AplicationContext文件,也會出現不能正常啟動,但是不能提示是什么錯誤.所以在新手開發程序的過程應仔細注意這些問題

           

          附:在SpringApplicationContext的配置文件中,提供了import元素節點,可以在當前模塊中導入bean文件

          ApplicationContext文件,

          <beans>

              <bean id="orderDAO" class="demo.sales.dao.hibernate.HibernateOrderDAO">

              </bean>

              <import resource="Order_bean.xml"/>

          </beans>

          主站蜘蛛池模板: 江北区| 松溪县| 海口市| 宜兰县| 康保县| 永安市| 乐业县| 红桥区| 万安县| 大英县| 阿拉尔市| 额尔古纳市| 铜川市| 铁力市| 庆元县| 繁峙县| 台北县| 都兰县| 互助| 奉节县| 濮阳县| 彩票| 久治县| 田林县| 屏边| 莱州市| 西贡区| 卢湾区| 旬阳县| 陈巴尔虎旗| 拉萨市| 龙井市| 申扎县| 乌鲁木齐市| 玉门市| 辽阳市| 芜湖市| 嘉善县| 杭锦后旗| 德阳市| 汕头市|