逝者如斯夫

          靜而思之

          導航

          留言簿(62)

          隨筆分類

          最新隨筆

          搜索

          •  

          最新評論

          閱讀排行榜

          關于 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 閱讀(1121) 評論(0)  編輯  收藏 所屬分類: Spring


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


          網站導航:
           
          主站蜘蛛池模板: 清河县| 北流市| 长乐市| 永福县| 广丰县| 镇康县| 沙河市| 阿荣旗| 于都县| 松潘县| 沙湾县| 扬中市| 罗田县| 东山县| 南京市| 乾安县| 绥中县| 广西| 三亚市| 新乡市| 大厂| 巫溪县| 甘南县| 万山特区| 博爱县| 商南县| 泰和县| 龙里县| 海城市| 南溪县| 泾源县| 东港市| 东山县| 芦山县| 收藏| 红桥区| 诸暨市| 吉林省| 辽中县| 桦甸市| 顺平县|