1、首先开启空间: xmlns:context=”http://www.springframework.org/schema/context”
    http://www.springframework.org/schema/context
    https://www.springframework.org/schema/context/spring-context.xsd
    2、使用context:property-placeholder标签,location:指定文件路径
    3、使用${属性名}获取配置文件数据

    1. <?xml version="1.0" encoding="UTF-8"?>
    2. <beans xmlns="http://www.springframework.org/schema/beans"
    3. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    4. xmlns:context="http://www.springframework.org/schema/context"
    5. xsi:schemaLocation="http://www.springframework.org/schema/beans
    6. https://www.springframework.org/schema/beans/spring-beans.xsd
    7. http://www.springframework.org/schema/context
    8. https://www.springframework.org/schema/context/spring-context.xsd">
    9. <context:property-placeholder location="classpath:data.properties" />
    10. <bean id="userDao" class="com.example.dao.Impl.UserDaoImpl">
    11. <property name="userName" value="${username}" />
    12. <property name="password" value="${pwd}" />
    13. </bean>
    14. <bean id="bookDao" class="com.example.dao.Impl.BookDaoImpl" />
    15. <bean id="userService" class="com.example.service.Impl.UserServiceImpl">
    16. <property name="userDao" ref="userDao" />
    17. <property name="bookDao" ref="bookDao" />
    18. </bean>
    19. </beans>