Installation and use of Lombok plugin in IDEA
The advantage of this plugin is that it can make our code more concise and reduce some repetitive work. The most commonly used is @Data annotation, such as @Data annotation on the entity class, each attribute of the entity class does not need to write get and set .
installation method:
1. File → Settings → Plugins, enter mybatis plugin, if you do n’t find it locally, you can click Search in repositories (or directly click Browse repositories to enter the search). After finding the Free MyBatis plugin, select Install to install, you need to restart after installation IDEA.
Instructions:
After installation, it can be used directly in the form of comments. For example, use @Data annotation to create a new User entity class, and then add @Data annotation directly in front of the class, so that the attributes in this entity class do not need get and set methods, as shown below:
There are some more commonly used annotations, such as:
@AllArgsConstructor is added to the class to generate a constructor with all parameters of the entity class.
@NoArgsConstructor is added to the class to generate a parameterless constructor.
@RequiredArgsConstructor is added to the class and used with the @NonNull annotation to generate a constructor with the specified parameters. For example, add @NonNull annotation in front of the age attribute, then the User generates a construction method that requires the age parameter.
@Getter is added to the class to generate getter methods for all attributes of the entity class.
@Setter is added to the class to generate setter methods for all properties of the entity class.
@ToString is added to the class, and the toString () method is called to output the values of all attributes in the entity class.
The advantage of this plugin is that it can make our code more concise and reduce some repetitive work. The most commonly used is @Data annotation, such as @Data annotation on the entity class, each attribute of the entity class does not need to write get and set .
installation method:
1. File → Settings → Plugins, enter mybatis plugin, if you do n’t find it locally, you can click Search in repositories (or directly click Browse repositories to enter the search). After finding the Free MyBatis plugin, select Install to install, you need to restart after installation IDEA.
Instructions:
After installation, it can be used directly in the form of comments. For example, use @Data annotation to create a new User entity class, and then add @Data annotation directly in front of the class, so that the attributes in this entity class do not need get and set methods, as shown below:
There are some more commonly used annotations, such as:
@AllArgsConstructor is added to the class to generate a constructor with all parameters of the entity class.
@NoArgsConstructor is added to the class to generate a parameterless constructor.
@RequiredArgsConstructor is added to the class and used with the @NonNull annotation to generate a constructor with the specified parameters. For example, add @NonNull annotation in front of the age attribute, then the User generates a construction method that requires the age parameter.
@Getter is added to the class to generate getter methods for all attributes of the entity class.
@Setter is added to the class to generate setter methods for all properties of the entity class.
@ToString is added to the class, and the toString () method is called to output the values of all attributes in the entity class.