博文

目前显示的是标签为“annotation”的博文

Spring - context:annotation-config 与 context:component-scan 的区别与使用

<context:annotation-config> is used to activate annotations in beans already registered in the application context (no matter if they were defined with XML or by package scanning <context:component-scan> can also activate annotations in beans but also scans packages to find and register beans within the application context. To use annotations like @Required, @Autowired etc you need at least <context:annotation-config> that is because "annotations are a nice feature but by themselves they do nothing whatsoever. They just annotate stuff. You need a processing tool to find the annotations and do something with them. <context:annotation-config> to the rescue. This activates the actions for the annotations that it finds on the beans defined in the same application context where itself is defined." But since <context:annotation-config> only works with beans that has already been registered. If we don't manually register those beans in ...

Intro to annotation p2

Annotations: JDK 5 (Tiger) contains two types of annotations: Simple annotations: These types of annotations are used to annotate the code only. We can not use these types of annotations for creating the custom annotation type. Meta annotations: Also known as annotations of annotations are used to annotate the annotation-type declaration. Simple annotations: JDK 5 includes three types of simple annotations. Override Depricated Suppresswarnings Meta-Annotations (Annotation Types): There are four types ofm Meta annotations (or annotations of annotations) defined by the JDK 5. These are as follows: Target Retention Documented Inherited Target annotation: Target annotation specifies the elements of a class to which annotation is to be applied. Here is the listing of the elements of the enumerated types as its value: @Target(ElementType.TYPE)—applicable to any element of a class. @Target(ElementType.FIELD)—applicable to field or property....