In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-29 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly explains "how to use Lombok". The content in the article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn how to use Lombok.
To put it simply, Lombok is to equip your mainframe with wingmen, simplify code development, and make Java more like the improved JVM language of Kotlin or Scala. With Lombok, you can omit a lot of repetitive code like Getter and Setter, and focus more on business development, which is convenient for maintenance.
Lombok's official website Project Lombok
The principle of Lombok is that after compiling and generating AST, the AST is modified according to the annotations, such as adding Getter and Setter methods, and then using the modified AST to generate bytecode.
If you want to do a good job, you must first sharpen its tools. Install the Lombok plug-in for IDEA first.
What's important to know is that Lombok is different from normal annotations in that it actually runs after the code is compiled, while general custom annotations actually run at run time-- usually get the contents of the annotations through reflection and then continue.
So you have to configure it and select Enable annotation processing.
After the configuration is complete, you can add Lombok dependencies. Take Maven as an example
Org.projectlombok
Lombok
True
By the way, in pursuit of faster dependence on download speed, you can configure the image as the domestic server address, for example, I configure it as the image address of Aliyun.
Alimaven
Aliyun maven
Http://maven.aliyun.com/nexus/content/groups/public
Central
Take the simplest POJO as an example
@ Data
@ AllArgsConstructor
@ NoArgsConstructor
Public class User {
Private long id
Private String name
Private int age
}
With these annotations added, the actual User generated is
You can see that the automatic help generates two constructors and a series of Getter and Setter methods.
Check out the stability features supported by Lombok
Thank you for your reading, the above is the content of "how to use Lombok", after the study of this article, I believe you have a deeper understanding of how to use Lombok, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.