The use of lombok components and GenerateAllSetter plug-ins

lombok component

The main function of the lombok component is to make the written code more elegant, (the essence is to quickly help us write the getter setter method toString method construction method, as well as the log framework tool class.

The first step: idea development tool to install Plugins plug-in

image-20221226202533815

Step 2: Set the current project to enable the annotation function and apply it

image-20221226202718022

Step 3: On the current project module, add the lombok.jar component dependency.

Download the lombok.jar dependency. Address: http://projectlombok.org

If it is a maven project, then it is relatively simple, just configure it in the pom.xml file. Now we are an ordinary project of idea java, so we need to download lombok.jar by ourselves, and then add it.

image-20221226203407197

Add dependencies:

image-20221226203521746

Once added, it can be applied.

Create a Book class.

@Data//封装
@AllArgsConstructor//有参构造
@NoArgsConstructor//无参构造
public class Book {
    
    
    private String bookName;
    private String author;
    private  String type;
    private LocalDateTime protime;
}

Use the shortcut key alt+7 to view

image-20221226204627544

The GenerateAllSetter plugin uses

The first step: idea development tool to install Plugins plug-in

image-20221226205141827

Step 2: Restart the idea development tool, and then it can be used.

Taking the above Book as an example, create a BookDemo class. Just put the mouse on the book and use the shortcut key Alt+Enter.

image-20221226205531305

Guess you like

Origin blog.csdn.net/qq_59088934/article/details/128449466