Spring注解使用错误的总结
错误一 本身类是new出来的,不是通过spring注入的
错误二 配置文件没有加入 <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-2.5.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd">
错误三 配置文件没有 <context:component-scan base-package="com" />
错误四 配置文件没有加 <context:annotation-config/> (不过后来的测试发现加不加都可以)
主要发现还是配置的问题