Spring Boot Annotations
Spring Boot Annotations
@Entity: This annotation allows entity manager to use this class and puts it in context.
@Column(name = "age"): denotes a column in the database with which this field will be associated.
@Transactional: This annotation indicates that the method will be executed in the transaction. Spring
will take care of transaction management.
Annotation Use Description
@Autowir Construct Declares a constructor, field, setter
ed or, Field, method, or configuration method to
Method be autowired by type. Items annotated
with @Autowired do not have to be
public.
@Configur Type Used with <context:springconfigured>
able to declare types whose properties
should be injected, even if they are not
instantiated by Spring. Typically used
to inject the properties of domain
objects.
@Order Type, Defines ordering, as an alternative to
Method, implementing the org.
Field springframework.core.Ordered
interface.
@Qualifier Field, Guides autowiring to be performed by
Parameter means other than by type.
, Type,
Annotatio
n Type
@Require Method Specifies that a particular property
d (setters) must be injected or else the
configuration will fail.
@Scope Type Specifies the scope of a bean, either
singleton, prototype, request, session,
or some custom scope.
@Compon Type Generic stereotype annotation for any
ent Spring-managed component.
@Controll Type Stereotypes a component as a Spring
er MVC controller.
@Reposito Type Stereotypes a component as a
ry repository. Also indicates that
SQLExceptions thrown from the
component's methods should be
translated into Spring
DataAccessExceptions.
@Service Type Stereotypes a component as a service.
@InitBind Method Annotates a method that customizes
er data binding.
@ModelAt Parameter When applied to a method, used to
tribute , Method preload the model with the value
returned from the method. When
applied to a parameter, binds a model
attribute to the parameter. table
@Request Method, Maps a URL pattern and/or HTTP
Mapping Type method to a method or controller
type.
@Request Parameter Binds a request parameter to a
Param method parameter.
@SessionA Type Specifies that a model attribute should
ttributes be stored in the session.
@Transact Method, Declares transactional boundaries and
ional Type rules on a bean and/or its methods.
JMX Annotations:
Aspect Annotations:
@AccessThe @Access annotation is used to specify the access type of the associated entity class,
mapped superclass, or the embeddable class and entity attribute.
@ColumnThe @Column annotation is used to specify the mapping between a basic entity attribute and
the database table column.
@IdThe @Id annotation specifies the entity identifier. An entity must always have an identifier
attribute, which is used when loading the entity in a given Persistence Context.
See the Identifiers section for more info.
@JoinTableThe @JoinTable annotation is used to specify the link table between two other database
tables.
@LobThe @Lob annotation is used to specify that the currently annotated entity attribute represents a
large object type.
@ManyToManyThe @ManyToMany annotation is used to specify a many-to-many database
relationship.
@OrderByThe @OrderBy annotation is used to specify the entity attributes used for sorting when
fetching the currently annotated collection.
@PersistencePropertyThe @PersistenceProperty annotation is used by
the @PersistenceContext annotation to declare JPA provider properties that are passed to the underlying
container when the EntityManager instance is created.
@VersionThe @Version annotation is used to specify the version attribute used for optimistic locking.