首页 > 编程语言 > 详细

Spring基于注解的IOC配置

时间:2019-12-25 10:50:56      阅读:65      评论:0      收藏:0      [点我收藏+]

Spring.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:context="http://www.springframework.org/schema/context"
       xsi:schemaLocation="http://www.springframework.org/schema/beans
        http://www.springframework.org/schema/beans/spring-beans.xsd
        http://www.springframework.org/schema/context
        http://www.springframework.org/schema/context/spring-context.xsd">
   <!-- &lt;!&ndash;把对象的创建交给spring来管理&ndash;&gt;
    <bean id="accountService" class="com.itheima.service.impl.AccountServiceImpl"></bean>
    <bean id="accountDao" class="com.itheima.dao.impl.AccountDaoImpl"></bean>-->
   <!--告知spring在创建容器时要扫描的包,配置所需要的标签不是在beans的约束中,而是一个名称
      context名称空间和约束
   -->
   <context:component-scan base-package="com.itheima"></context:component-scan>
</beans>

Spring基于注解的IOC配置

原文:https://www.cnblogs.com/naigai/p/12095223.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!