xml:一般情况下使用xml对bean进行管理,配置id和class
注解:使用注解的方式对属性进行注入。
加入配置:只要在xml中加入<context:annotation-config />即可,这样@Autowired、@Resource等注解就生效了。不需要配置
<context:component-scan base-package=" "></context:component-scan>去扫描包了。
xml:一般情况下使用xml对bean进行管理,配置id和class
注解:使用注解的方式对属性进行注入。
加入配置:只要在xml中加入<context:annotation-config />即可,这样@Autowired、@Resource等注解就生效了。不需要配置
<context:component-scan base-package=" "></context:component-scan>去扫描包了。