请高手指教不论什么方法好用就行
<?xml version="1.0" encoding="UTF-8"?>
<beans>
       <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource">
<property name="driverClassName" value="com.mysql.jdbc.Driver"/>
<property  name="url"value="jdbc:mysql://10.17.255.20:3306/ewsdb?characterEncoding=UTF-8" />
<property name="username" value="ews" />
<property name="password" value="111111" />
<property name="initialSize" value="5" />
<property name="maxActive" value="100" />
<property name="maxIdle" value="30" />
<property name="maxWait" value="1000" />
<property name="defaultAutoCommit" value="true" />
</bean>
<beans>
我要取得上述  value中的值可以  当XML读取  也或者Spring有方法可以取得请高手说下主要获取
url  username  password  中value的值

解决方案 »

  1.   

    new个容器出来,然后根据id获取相关的bean,再读取数据~
      

  2.   

            <property name="driverClassName" value="com.mysql.jdbc.Driver"/>
            <property  name="url"value="jdbc:mysql://10.17.255.20:3306/ewsdb?characterEncoding=UTF-8" />
            <property name="username" value="ews" />
            <property name="password" value="111111" />
            <property name="initialSize" value="5" />
            <property name="maxActive" value="100" />
            <property name="maxIdle" value="30" />
            <property name="maxWait" value="1000" />
            <property name="defaultAutoCommit" value="true" />
    这些值都可以配置xxxx.properties
    文件中
    然后把路径放到src下面然后再spring的xml中可以通过${}
    来获取下面是copy别人的参考下
    <bean id="propertyConfigurer"
    class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
    <!-- 数据库信息文件 -->
    <property name="location">
    <value>WEB-INF/hibernate.properties</value>
    </property>
    </bean> <!-- 数据源 -->
    <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"
    destroy-method="close">
    <property name="driverClassName">
    <value>${driverClassName}</value>
    </property>
    <property name="url">
    <value>${url}</value>
    </property>
    <property name="username">
    <value>${username}</value>
    </property>
    <property name="password">
    <value>${password}</value>
    </property>

    </bean>