DI入门 -2025/1/1

applicationContext.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"
       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
        <!--bean标签标示配置bean
       id属性标示给bean起名字
       class属性表示给bean定义类型
   -->
        <bean id="bookService" class="com.stdu.service.impl.BookServiceImpl">
                <!--配置server与dao的关系-->
                <!--property标签表示配置当前bean的属性
                        name属性表示配置哪一个具体的属性
                        ref属性表示参照哪一个bean
                -->
                <property name="bookDao" ref="bookDao"></property>
        </bean>
        <bean id="bookDao" class="com.stdu.dao.impl.BookDaoImpl">
        </bean>
</beans>
posted @ 2025-01-01 22:49  XYu1230  阅读(8)  评论(0)    收藏  举报