This is the first article I participated in beginners’ introduction

Idea useful plug-ins and tips

1, Lombok

Java is an object-oriented language. In the development process, we need to write a lot of JavaBean, although Idea can automatically Generate Getter, Setter and other information (shortcut key Alt+ INSERT, or right click Generate), but it is also a lot of trouble, and it is quite troublesome to modify. Lombok has made the programmer’s job a lot easier, and I’m sure everyone uses it.

The installation

File -> Setting

Then find the plugin. If you can’t find it, search for it and install it. After the first installation, you will be prompted to restart Idea.

Although we have installed this plug-in, it is not directly available and we need to configure it.

Configure annotation handlers

Again in Setting, go to Build, Execution, Deployment->Compiler->Annotation Processors and click Enable Annotation Processors to Enable the Annotation Processors.

Maven is introduced into

         <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
        </dependency>
Copy the code

use

package com.wangscaler.commons.bean;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/ * * *@author wangscaler
 * @date2021.07.01 15:02 * /
@Data
@AllArgsConstructor
@NoArgsConstructor
public class DataResult<T> {
    private Integer code;
    private String msg;
    private T data;

    public DataResult(Integer code, String msg) {
        this(code, msg, null); }}Copy the code
  • Using the @data annotation will generate getters, setters, toString, equals, hashCode methods instead.
  • Using the @noargsconstructor annotation, the no-argument constructor is generated.
  • Using the @allargsconstructor annotation, a full-parameter constructor is generated
  • The use of more annotations, please baidu, here do not do too much introduction.

All in all, the benefits of this plug-in are numerous and must be installed. Of course, if other people in your company do not install but you install, collaborative work is certainly a problem, then do not install.

2. Automatically generate author information

During development, we found that some Class files were labeled with author and date. If we manually generate every file, it is also very troublesome, and these things have no practical significance worth our time to write, we can use templates to generate.

Write a template

File ->Settings ->Editor ->File and Code Templates, then select Class on the right and type in public

/ * * *@author WangScaler
 * @date ${DATE} ${TIME}
 */
 
Copy the code

The author here isWangScalerYou can exchange it for your own.

use

When we create a new Class, we will automatically carry this comment information with us.

digression

Here are the two most practical and will continue to update the RainbowBrackets…. Plug-ins, you all have what practical plug-ins to share, we learn to learn, improve efficiency.