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
- @Test — The JUnit annotation that marks a method as a test to discover and run.
- @Service — A Spring annotation that marks a class as a service bean so component scanning discovers and creates it.
- Jakarta Validation — The Jakarta standard for declaring input rules as annotations on fields, such as @NotBlank and @Positive, and checking them automatically.
Taught in
- Testing Basics With JUnit 5 — Modern Java: Virtual Threads & High-Throughput Services
- Dependency Injection And The IoC Container — Modern Java: Virtual Threads & High-Throughput Services
- Spring Boot Auto Configuration — Modern Java: Virtual Threads & High-Throughput Services
- Controllers And Routing — Modern Java: Virtual Threads & High-Throughput Services
- Validation — Modern Java: Virtual Threads & High-Throughput Services
- Persistence With JPA And Hibernate — Modern Java: Virtual Threads & High-Throughput Services
- Inheritance, Overriding And Object's Methods — Oracle Certified Professional: Java SE 21 Developer (1Z0-830) Exam Prep
- Interfaces: Default, Static And Private Methods — Oracle Certified Professional: Java SE 21 Developer (1Z0-830) Exam Prep