要在Spring 中配置参数 如
jdbc.driverClassName=org.hsqldb.jdbcDriver
jdbc.url=jdbc:hsqldb:hsql://localhost:9002
jdbc.username=sa
jdbc.password=
必须在配置加入 org.springframework.beans.factory.config.PropertyPlaceholderConfigurer
用来读取相应的properties 如
<bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="locations">
<list>
<value>WEB-INF/jdbc.properties</value>
</list>
</property>
</bean>
jdbc.driverClassName=org.hsqldb.jdbcDriver
jdbc.url=jdbc:hsqldb:hsql://localhost:9002
jdbc.username=sa
jdbc.password=
必须在配置加入 org.springframework.beans.factory.config.PropertyPlaceholderConfigurer
用来读取相应的properties 如
<bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="locations">
<list>
<value>WEB-INF/jdbc.properties</value>
</list>
</property>
</bean>
本文介绍如何在Spring框架中配置数据库连接属性,并使用PropertyPlaceholderConfigurer来读取外部properties文件。

1万+

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



