applicatonContext.xml
<?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:p="http://www.springframework.org/schema/p"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans
https://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context
https://www.springframework.org/schema/context/spring-context.xsd">
<!--1.加载context命名空间支持,xmlns:context="http://www.springframework.org/schema/context"-->
<!--2.加载配置文件-->
<context:property-placeholder location="classpath:*.properties"/>
<!--<bean id="userDao" class="com.itheima.Dao.impl.UserDaoImpl">
<property name="username" value="${username}"/>
<property name="password" value="${pwd}"/>
</bean>
<bean id="bookDao" class="com.itheima.Dao.impl.BookDaoImpl"/>
<bean id="userService" class="com.itheima.service.impl.UserServiceImpl">
<property name="userDao" ref="userDao"/>
<property name="bookDao" ref="bookDao"/>
</bean>-->
<!--<bean id="userDao" class="com.itheima.Dao.impl.UserDaoImpl">
<property name="username" value="${username}"/>
<property name="password" value="${pwd}"/>
</bean>
<bean id="bookDao" class="com.itheima.Dao.impl.BookDaoImpl"/>
<bean id="userService" class="com.itheima.service.impl.UserServiceImpl">
<property name="userDao" ref="userDao"/>
<property name="bookDao" ref="bookDao"/>
</bean>-->
<import resource="applicationContext-user.xml"/>
<import resource="applicationContext-book.xml"/>
<import resource="applicationContext-book2.xml"/>
</beans>
applicatonContext-user.xml
<?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:p="http://www.springframework.org/schema/p"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans
https://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context
https://www.springframework.org/schema/context/spring-context.xsd">
<bean id="userDao" class="com.itheima.Dao.impl.UserDaoImpl">
<property name="username" value="${username}"/>
<property name="password" value="${pwd}"/>
</bean>
<bean id="userService" class="com.itheima.service.impl.UserServiceImpl">
<property name="userDao" ref="userDao"/>
<property name="bookDao" ref="bookDao"/>
</bean>
</beans>
applicatonContext-book.xml
<?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:p="http://www.springframework.org/schema/p"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans
https://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context
https://www.springframework.org/schema/context/spring-context.xsd">
<bean id="bookDao" class="com.itheima.Dao.impl.BookDaoImpl">
<property name="num" value="1"/>
</bean>
</beans>