@Data comments on the use and installation of IDEA

 

  Usually to create entity classes in the development process when the operation is often: first to write member variables, and then provide getXxx (), setXxx () method, and then need to look at providing toString methods. In this way not only will find each entity to write a class, you would have a lot of the same operation, and the amount of code looks a lot, very long, is not simple. So, @ Data This annotation will be able to bring to our development process is very easy to use.

  First, @ Data this annotation is an annotation in lombok package (the package but fortunately a lot of useful notes, are interested in children's shoes can go to find the next yo ~), and this comment is in class on

1
2
3
4
5
6
7
8
9
10
@Data
public  class  Test {
     
    
     private  String id;
     
     private  String name;
     
 
}

  This comment actually help your class provides getXxx (), setXxx () method, equals (), hashCode (), toString () methods. That just wrote this comment on your class, it does not need to regenerate get, set, toString methods such as the.

  When you were using when the annotation, and then create an instance, he calls the get or set method, you'll find the error code. This is because you have not installed this plug-in lombok. Here's how to install it on IDEA:

First, opening the Settings under File, then Plugins, then click on the following Browse repositories, then in the search box search lombok, then there is a install button to install, restart after installation under IDEA will find the error is gone.

  Usually to create entity classes in the development process when the operation is often: first to write member variables, and then provide getXxx (), setXxx () method, and then need to look at providing toString methods. In this way not only will find each entity to write a class, you would have a lot of the same operation, and the amount of code looks a lot, very long, is not simple. So, @ Data This annotation will be able to bring to our development process is very easy to use.

  First, @ Data this annotation is an annotation in lombok package (the package but fortunately a lot of useful notes, are interested in children's shoes can go to find the next yo ~), and this comment is in class on

1
2
3
4
5
6
7
8
9
10
@Data
public  class  Test {
     
    
     private  String id;
     
     private  String name;
     
 
}

  This comment actually help your class provides getXxx (), setXxx () method, equals (), hashCode (), toString () methods. That just wrote this comment on your class, it does not need to regenerate get, set, toString methods such as the.

  When you were using when the annotation, and then create an instance, he calls the get or set method, you'll find the error code. This is because you have not installed this plug-in lombok. Here's how to install it on IDEA:

First, opening the Settings under File, then Plugins, then click on the following Browse repositories, then in the search box search lombok, then there is a install button to install, restart after installation under IDEA will find the error is gone.

Guess you like

Origin www.cnblogs.com/zhuyeshen/p/11018305.html