Java annotation

A marker starting with @, such as @Test or @Service, that attaches information to code for the compiler, tools or frameworks to act on.

In more detail

Annotations do nothing by themselves; something reads them. JUnit finds @Test methods, Spring creates beans from @Service classes, and Jakarta Validation checks @NotBlank fields. They let frameworks be configured right next to the code they affect.

Examples

@Test
@GetMapping("/orders")

Related terms

Taught in

References

Certification courses