我们只需要在applicationContext.xml中加上这个bean的配置
<bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"> <property name="locations"> <list> <value>/WEB-INF/jdbc.properties</value> <value>/WEB-INF/threadPool.properties</value> </list> </property> </bean> 顺带提一句:spring中设置数据源的类
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close"> <property name="driverClassName" value="${jdbc.driverClassName}" /> <property name="url" value="${jdbc.url}" /> <property name="username" value="${jdbc.user}" /> <property name="password" value="${jdbc.password}" /> <property name="maxActive" value="${jdbc.maxActive}" /> <property name="initialSize" value="${jdbc.initialSize}" /> <property name="maxIdle" value="${jdbc.maxIdle}" /> <property name="removeAbandoned" value="${jdbc.removeAbandoned}" /> <property name="removeAbandonedTimeout" value="${jdbc.removeAbandonedTimeout}" /> <property name="logAbandoned" value="${jdbc.logAbandoned}" /> <property name="validationQuery" value="${jdbc.validationQuery}" /> <property name="testOnBorrow" value="${jdbc.testOnBorrow}" /> </bean>这就是使用spring进行数据源设定
时间: 2024-11-05 22:09:36