首页 > 技术文章 > spring 注解

lilyjia 2016-10-18 09:27 原文

<context:annotation-config/>与
<context:component-scan base-package="com.jll"></context:component-scan>
有什么区别?

 

<context:annotation-config/>是两个bean之间注入的关系,具体的bean只能在xml文件里面配置,注入的时候是通过名字进行注入的

<context:component-scan base-package="com.jll"></context:component-scan>是扫描base-package包里面的类,加了@component,@service,@Repository,@controller这类的注解就说明这个类的对象是给spring管理的,这个也是通过名字进行注入的

推荐阅读