Spring中@Autowired和@Resource的区别
其实这两者的功能应用都很相似,
@Autowired按Type匹配(可能存在多Bean问题)
@Resource按Name匹配(只要存在该Bean名称就可以完成自动装配)
其中@Resource中比较重要的有两个参数,分别是Name和Type
@Target({TYPE, FIELD, METHOD})
@Retention(RUNTIME)
public @interface Resource {
String name() default "";
Class<?> type() default java.lang.Object.class;
}