In this article, you are going to learn some of the most commonly used annotations in Quarkus and their purposes:
Quarkus Core Annotations
@ApplicationScoped
: Used to annotate a class whose instances are shared across the entire application. It is a type of CDI scope that defines the lifecycle of the annotated bean to be the same as the lifecycle of the application.@Singleton
: Used to annotate a class whose instances are shared across the entire application. It is a type of CDI scope that defines the lifecycle of the annotated bean to be the same as the lifecycle of the application.@Inject
: Used to annotate a field, constructor parameter, or setter method to indicate that the value of the field or parameter should be injected by CDI.@Produces
: Used to annotate a method that produces a bean to be injected by CDI.@ConfigProperty
: Used to annotate a field, constructor parameter, or setter method to indicate that its value should be injected from the configuration.
RESTful Web Services Annotations
@Path
: Used to annotate a resource class or method to specify the URI path that should be mapped to the resource.@GET
: Used to annotate a method to indicate that it should handle HTTP GET requests.@POST
: Used to annotate a method to indicate that it should handle HTTP POST requests.@PUT
: Used to annotate a method to indicate that it should handle HTTP PUT requests.@DELETE
: Used to annotate a method to indicate that it should handle HTTP DELETE requests.@Produces
: Used to annotate a method to indicate the media type of the response it produces.
Hibernate Annotations
@Entity
: Used to annotate a class to indicate that it is a persistent entity in the database.@Id
: Used to annotate a field to indicate that it is the primary key of the entity.@GeneratedValue
: Used to annotate a field to specify the strategy used to generate the primary key value.@Column
: Used to annotate a field to specify the mapping between the entity attribute and the database column.
Quarkus Messaging Annotations
@Incoming
: Used to annotate a method to indicate that it should handle incoming messages from a messaging system.@Outgoing
: Used to annotate a method to indicate that it produces outgoing messages to a messaging system.@Channel
: Used to annotate a method to indicate the name of the messaging channel.
These are just a few of the most commonly used annotations in Quarkus. There are many more annotations available that provide additional functionality, such as caching, security, and metrics.
I hope this helps, you!!
More such articles:
https://www.youtube.com/channel/UCiTaHm1AYqMS4F4L9zyO7qA
\==========================**=========================
If this article adds any value to you then please clap and comment.
Let’s connect on Stackoverflow, LinkedIn, & Twitter.