mybatisplus自动生成 lombok注解
时间: 2023-09-19 10:06:31 浏览: 111
mybatisplus+swagger+lombok的使用
MyBatis Plus indeed provides support for generating Lombok annotations automatically. By using the `@Data` annotation from Lombok, you can generate getter, setter, and other common methods for your entity classes. Here's an example of how to use it:
1. Firstly, make sure you have added the Lombok dependency in your project's pom.xml file:
```xml
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</dependency>
```
2. In your entity class, add the `@Data` annotation from Lombok to enable the generation of common methods:
```java
import lombok.Data;
@Data
public class User {
private Long id;
private String name;
private Integer age;
}
```
With this setup, MyBatis Plus will automatically generate the getter, setter, `equals()`, `hashCode()`, and `toString()` methods for the fields in your `User` class.
Note that you should also configure Lombok properly in your IDE to enable the automatic recognition of Lombok annotations.
阅读全文