You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@Bean - Annotated method produces a bean managed by the Spring IoC container
Stereotype annotations
@Component - Marks annotated class as a bean found by the component-scanning and loaded into the application context
@Controller - Marks annotated class as a bean for Spring MVC containing request handler
@RestController - Marks annotated class as a @Controller bean and adds @ResponseBody to serialize returned results as messages
@Configuration - Marks annotated class as a Java configuration defining beans
@Service - Marks annotated class as a bean (as convention usually containing business logic)
@Repository - Marks annotated class as a bean (as convention usually providing data access) and adds auto-translation from SQLException to DataAccessExceptions
Bean state
@PostConstruct - Annotated method is executed after dependency injection is done to perform initialization
@PreDestroy - Annotated method is executed before the bean is destroyed, e.g. on the shutdown
Configuration
@Import - Imports one or more Java configuration classes @Configuration
@PropertySource - Indicates the location of applicaiton.properties file to add key-value pairs to Spring Environment
@Value - Annotated fields and parameters values will be injected
@ComponentScan - Configures component scanning @Compenent, @Service, etc.
Bean properties
@Lazy - Annotated bean will be lazily initialized on the first usage
@Profile - Indicates that beans will be only initialized if the defined profiles are active
@Scope - Defines bean creation scope, e.g. prototype, singleton, etc.
@DependsOn - Explicitly defines a dependency to other beans in terms of creation order
@Order - Defines sorting order if injecting a list of beans, but it does not resolve the priority if only a single bean is expected
@Primary - Annotated bean will be picked if multiple beans can be autowired
@Conditional - Annotated bean is created only if conditions are satisfied
@CreationTimestamp - Annotated field contains the timestamp when an entity was stored for the first time
@UpdateTimestamp - Annotated field contains the timestamp when an entity was updated last time
@ManyToOne - Indicates N:1 relationship, the entity containing annotated field has a single relation to an entity of other class, but the other class has multiple relations
@JoinColumn - Indicates a column for joining entities in @ManyToOne or @OneToOne relationships at the owning side or unidirectional @OneToMany
@MapsId - References joining columns of owning side of @ManyToOne or @OneToOne relationships to be the primary key of referencing and referenced entities