Spring Annotations
If you want to develop a Spring Application you need to know when to use which Annotation.
Dependency Injection
Spring’s dependency injection capability includes the following annotations:
Annotation | Explanation |
@Component | Generic stereotype for any Spring-managed component. |
@Service | Indicates that an annotated class is a service. |
@Value | Injection mechanism for fields and methods that indicates a default value. Often used to get values from property files. |
Configuration
Annotation | Explanation |
@Qualifier | Associates a value with a particular argument. More finely tuned way than @Order and @Priority to control selection. |
@Profile | Indicates that a component is eligible for registration when one or more specified profiles are active. You can also use @Profile({"default"}) to define a default profile, if no Profile is actively selected. |