在使用@Data之后,Lombok不会创建getter和setter方法 [英] Lombok does not create getter and setter methods after using @Data

查看:319
本文介绍了在使用@Data之后,Lombok不会创建getter和setter方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有 gradle spring boot 项目,我在 build.gradle 中添加了 Lambok 依赖项.我创建了一个模型类,并想使用lombok.我添加了@Data批注,但仍未生成setter和getter方法.示例代码:

I have gradle spring boot project and I added Lambok dependency in build.gradle. I created one model class and want to use lombok. I have added @Data annotation but still setter and getter methods are not generated. Sample code :

import lombok.Data;

@Data
public class TestLambok {
    private int id;
    private String name;
    private String summary;

}

推荐答案

要使用Lombok插件,您需要执行以下步骤(至少在IntelliJ上如此):

For use Lombok Plugin, you need the following steps (at least on IntelliJ):

  • 安装Lombok插件
  • 启用注释处理
  • 重启IDE

有关更多信息,您可以阅读以下文章: https://www.baeldung.com/lombok-ide

For more information you can read this post: https://www.baeldung.com/lombok-ide

这篇关于在使用@Data之后,Lombok不会创建getter和setter方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆