Full parsing of Java annotations

Source: Internet
Author: User

What is an annotation?

Concepts: Annotations (Annotation), also called Meta data. A description of the code level. It is a feature introduced in JDK1.5 and later versions, with classes, interfaces, and enumerations at the same level. It can be declared in front of packages, classes, fields, methods, local variables, method parameters, and so on, to explain these elements, comments.


Classification of annotations

1. By source

Bring your own annotations to the JDK

@Override means that the current method overrides the parent class
@Deprecation indicates that the method is obsolete, there are horizontal lines on the method, and warnings are used.
@SuppviseWarnings means to turn off some warning messages (notifies the Java compiler to ignore specific compilation warnings)

Third-party common annotations (example)

Spring: @Autowired @service @Repository

MyBatis: @InsertProvider @UpdateProvider @Option

Custom annotations

Meta annotations (annotated annotations)

2. Follow the operating mechanism

SOURCE annotations: Annotations only exist in the source code, compiled into a. class file will not exist.

Compile-time annotations: annotations exist in both the source and. class files, such as @override.

Runtime Annotations: It also works in the run phase, and even affects the annotations that run the logic, such as @autowired






Full parsing of Java annotations

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.