Lombok-Simplify your Java coding (jdk6+) __ajax

Source: Internet
Author: User

Recently, my colleague recommended a very useful Java library, let me very much hate their attention to the good things enough, but also lamented the cattle more people, the Java world more open source good things. Here to recommend it to everyone: Lombok.

Lombok is designed to simplify Java code writing, the IDE and compiler (Maven) support Lombok are required. First of all, how to use the specific:


The first step is to download the Lombok jar file https://projectlombok.org/download.html


The second step is to execute it and add it to the classpath of the development IDE eclipse.




3. Start the IDE, add Lombok dependencies to the project, and then add Lombok annotation to the Java file, and then the miracle comes and automatically adds a lot of code that can help simplify development and increase readability.

<dependency>
        <groupId>org.projectlombok</groupId>
        <artifactid>lombok</ artifactid>
        <version>1.16.10</version>
        <scope>provided</scope>
</ Dependency>
The Note:lombok function is generate class file, so scope is as good as provided.

Add data, Noargsconstructor, allargsconstructor in eclipse:


Maven compiled class file


Lombok has a lot of functions, can refer to https://projectlombok.org/features/index.html. For me, the usual include: Val, @Getter/@Setter, @NoArgsConstructor, @AllArgsConstructor, @Cleanup, @ToString, @Log4j2, @Slf4j, @ Nonnull


The specific principle can refer to: http://hannesdorfmann.com/annotation-processing/annotationprocessing101

Lombok Source code: https://github.com/rzwitserloot/lombok/

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.