<!-- ============ GENERAL DEFINITIONS========== -->
<!-- Configurer that replaces ${...} placeholders with values from a properties file -->
<!-- (in this case, JDBC-related settings for the dataSource definition below) -->
<bean id="propertyConfigurer"
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="location">
<value>classpath:spring/jdbc-oracle.properties</value>
</property>
</bean>
<!-- =========== RESOURCE DEFINITIONS ============ -->
<!-- Local DataSource that works in any environment -->
<bean id="dataSource"
class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName">
<value>${jdbc.driverClassName}</value>
</property>
<property name="url">
<value>${jdbc.url}</value>
</property>
<property name="username">
<value>${jdbc.username}</value>
</property>
<property name="password">
<value>${jdbc.password}</value>
</property>
</bean>
当jdbc-oracle.properties文件加载下后,${}即可取出其中的内容
本文详细介绍了如何使用Spring框架中的PropertyPlaceholderConfigurer配置类,将Oracle数据库的相关属性从properties文件中加载,实现灵活的数据源配置。
1747

被折叠的 条评论
为什么被折叠?



