<context:annotation-config>和 <context:component-scan>区别

<context:annotation-config>:注解扫描是针对已经在Spring容器里注册过的Bean

<context:component-scan>:不仅具备<context:annotation-config>的所有功能,还可以在指定的package下面扫描对应的bean

<context:annotation-config /><context:component-scan>同时存在的时候,前者会被忽略。

即使注册Bean,同时开启<context:annotation-config />扫描,@autowire,@resource等注入注解只会被注入一次,也即只加载一次

猜你喜欢

转载自www.cnblogs.com/kingdaqi/p/9181732.html