<!--开启注解扫描-->
<context:component-scan base-package="com.jiang">
<!--根据注解排除扫描-->
<!--<context:exclude-filter type="annotation"
expression="org.springframework.stereotype.Controller"/>-->
<!--根据类名排除扫描-->
<!--<context:exclude-filter type="assignable"
expression="com.jiang.controller.UserController"/>-->
<!--根据正则表达式(regex),切面(aspectj),自己实现一个类(custom),比较少用-->
<!--同理可以根据注解,类名,正则表达式,切面,自己实现一个类来包含扫描-->
<!--<context:include-filter type="annotation"
expression="org.springframework.stereotype.Controller"/>-->
</context:component-scan>
使用@Autowired来实现自动注入
·默认优先根据类型去匹配
·如果匹配到多个类型则会按照名字匹配
·如果名又没有匹配到则会报错:
原文:https://www.cnblogs.com/jqccan/p/14439010.html