bean.xml读取properties属性文件
<?xml version="1.0" encoding="UTF-8"?><beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:aop="http://www.springframework.org/schema/aop" xmlns:context="http://www.springframework.org/schema/context" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd"> <!-- 打开Spring的Annotation支持 --> <context:annotation-config/> <!-- 设定Spring 去哪些包中找Annotation --> <context:component-scan base-package="org"/> <bean id="dataSource" destroy-method="close"><property name="driverClassName" value="${jdbc.driverClassName}" /><property name="url" value="${jdbc.url}" /><property name="username" value="${jdbc.username}" /><property name="password" value="${jdbc.password}" /></bean><!-- 导入Src目录下的jdbc.properties文件 --><context:property-placeholder location="jdbc.properties"/></beans>
?jdbc.properties文件:
jdbc.driverClassName=com.mysql.jdbc.Driverjdbc.url = jdbc:mysql://localhost:3306/testjdbc.username = rootjdbc.password = root
?