99% of programmers are using Lombok. Is the principle so simple? I got one too| Recommended collection!!!

I believe most people are familiar with Lombok, but little is known about its implementation principle and disadvantages. This paper will start from the principle of Lombok and roll up a simple version of Lombok to let you understand the implementation principle behind this popular technology and its advantages and disadvantages.

brief introduction

Before talking about the principle, let's review Lombok (the old driver can skip this paragraph to see the principle part).

Lombok is a very popular open source project( https://github.com/rzwitserloot/lombok ), it can effectively solve the tedious and repetitive codes in Java projects, such as setter, getter, toString, equals, hashcode and non null judgment. Lombok can be used to effectively solve them.

use

1. Add Lombok plug-in

The Lombok plug-in must be installed in the IDE to call the code modified by Lombok normally. Take idea as an example, the adding steps are as follows:

The installation is completed, as shown in the figure below:

2. Add Lombok Library

Next, we need to add the latest Lombok library to the project. If it is a maven project, we need to add it directly in POM. Com Add the following configuration to XML:

<dependencies>
  <!-- https://mvnrepository.com/artifact/org.projectlombok/lombok -->
	<dependency>
		<groupId>org.projectlombok</groupId>
		<artifactId>lombok</artifactId>
		<version>1.18.12</version>
		<scope>provided</scope>
	</dependency>
</dependencies>
@H_502_44@
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>