使用注解扫描器context:component-scan 扫到的包才可以使用注解把class注入到spring上下文,如果不在context:component-scan 扫描范围内,则不能使用注解注入。