逝者如斯夫

          靜而思之

          導(dǎo)航

          留言簿(61)

          隨筆分類

          最新隨筆

          搜索

          •  

          最新評(píng)論

          閱讀排行榜

          關(guān)于 PropertyPlaceholderConfigurer

          在Spring中,使用PropertyPlaceholderConfigurer可以在XML配置文件中加入外部屬性文件,例如:

          ????<bean?id="propertyConfigurer"
          ??????????class
          ="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
          ????????
          <property?name="location"?value="classpath:config/jdoserver.properties"/>
          ????
          </bean>

          但是好像在屬性文件定義中卻不支持多個(gè)屬性文件的定義,比如不能這樣用config/*.properties。

          經(jīng)過查看源碼,發(fā)現(xiàn)可以使用locations屬性定義多個(gè)配置文件:
          <property?name="locations">
          ????????????
          <list>
          ????????????????
          <value>classpath:config/maxid.properties</value>
          ????????????????
          <value>classpath:config/jdoserver.properties</value>
          ????????????
          </list>
          </property>

          使用外部屬性后如下:

          ????<bean?id="dataSource"?class="org.springframework.jdbc.datasource.DriverManagerDataSource">
          ????????
          <property?name="driverClassName"?value="${jdbc.agent.driver}"/>
          ????????
          <property?name="url"?value="${jdbc.agent.main.url}"/>
          ????
          </bean>

          上面的例子是采用Spring DriverManagerDataSource包裝VJDBC Connection的用法,沒有提供連接池功能,只能作作簡單的單機(jī)連接。

          posted on 2007-11-27 18:19 ideame 閱讀(1120) 評(píng)論(0)  編輯  收藏 所屬分類: Spring


          只有注冊(cè)用戶登錄后才能發(fā)表評(píng)論。


          網(wǎng)站導(dǎo)航:
           
          主站蜘蛛池模板: 额济纳旗| 疏附县| 丽江市| 泽普县| 金川县| 出国| 襄樊市| 阿拉尔市| 东丽区| 浦东新区| 绥棱县| 固镇县| 石城县| 大安市| 来凤县| 侯马市| 高尔夫| 石阡县| 河南省| 洪湖市| 霍山县| 伊宁县| 蕉岭县| 即墨市| 宜兰县| 珠海市| 铜陵市| 工布江达县| 化德县| 贵德县| 大余县| 玉门市| 龙江县| 东方市| 化隆| 定远县| 肇东市| 胶州市| 东明县| 洪江市| 丰顺县|