沙漠中的魚(yú)

          欲上天堂,先下地獄
          posts - 0, comments - 56, trackbacks - 0, articles - 119
            BlogJava :: 首頁(yè) ::  :: 聯(lián)系 :: 聚合  :: 管理

          在業(yè)務(wù)項(xiàng)目開(kāi)發(fā)中,數(shù)據(jù)表比較多,把所有的配置信息放在一個(gè)文件就會(huì)顯得文件過(guò)于龐大,不好管理和維護(hù),所以就應(yīng)當(dāng)為每個(gè)應(yīng)當(dāng)模塊創(chuàng)建一個(gè)ApplicationContext文件,web.xml文件中

          Spring官方提供了一種加載多個(gè)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>

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

          <context-param>

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

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

          </context-param>

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

           

          還有另一種可能編譯不能正常起動(dòng)的原因,就是我在配置文件提供的路徑,如果路徑中找不不到任何相關(guān)的AplicationContext文件,也會(huì)出現(xiàn)不能正常啟動(dòng),但是不能提示是什么錯(cuò)誤.所以在新手開(kāi)發(fā)程序的過(guò)程應(yīng)仔細(xì)注意這些問(wèn)題

           

          附:在SpringApplicationContext的配置文件中,提供了import元素節(jié)點(diǎn),可以在當(dāng)前模塊中導(dǎo)入bean文件

          ApplicationContext文件,

          <beans>

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

              </bean>

              <import resource="Order_bean.xml"/>

          </beans>

          主站蜘蛛池模板: 伊宁县| 怀远县| 葫芦岛市| 遂宁市| 慈利县| 射阳县| 监利县| 栾城县| 磐石市| 克东县| 梧州市| 高要市| 梨树县| 太谷县| 遂川县| 枣庄市| 利川市| 花莲市| 夏津县| 万盛区| 红安县| 中江县| 高青县| 且末县| 泌阳县| 东海县| 巩留县| 泰和县| 屏山县| 松原市| 巴中市| 图片| 安溪县| 黄龙县| 阿巴嘎旗| 香格里拉县| 衡山县| 贡嘎县| 剑川县| 辉南县| 孝义市|