逝者如斯夫

          靜而思之
          數據加載中……

          關于 PropertyPlaceholderConfigurer

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

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

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

          經過查看源碼,發現可以使用locations屬性定義多個配置文件:
          <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的用法,沒有提供連接池功能,只能作作簡單的單機連接。

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


          只有注冊用戶登錄后才能發表評論。


          網站導航:
           
          主站蜘蛛池模板: 江永县| 托克逊县| 茂名市| 正宁县| 宜君县| 吉安县| 衡东县| 揭阳市| 望奎县| 无极县| 眉山市| 娱乐| 托克逊县| 黄浦区| 横峰县| 庐江县| 永丰县| 临猗县| 灵丘县| 徐水县| 成都市| 双峰县| 鄂托克前旗| 莒南县| 张家口市| 历史| 萨嘎县| 定南县| 奉节县| 肇东市| 三台县| 磐石市| 九龙坡区| 仁寿县| 合肥市| 江津市| 日喀则市| 西藏| 抚宁县| 侯马市| 广灵县|