简体   繁体   English

lombok @AllArgsConstructor构造函数

[英]lombok @AllArgsConstructor constructor

I am new to lombok. 我是龙目岛的新手。 I have defined the below model using lombok. 我使用lombok定义了以下模型。 However when I try to create a object of the model with parameters, it gives an error stating Paramterized connstructor is not defined . 但是,当我尝试使用参数创建模型的对象时,它给出了一个错误,指出Paramterized connstructor is not defined From what I have read, @AllArgsConstructor , @NoArgsConstructor should create both a paramterized and default constructor. 从我所读的内容中, @AllArgsConstructor@NoArgsConstructor应该创建参数化的和默认的构造函数。 I am able to access my parameters so I am sure lombok is setup correctly. 我可以访问我的参数,因此可以确保正确安装了lombok。

Am I missing something here? 我在这里想念什么吗?

 @Data
 @AllArgsConstructor
 @NoArgsConstructor
 public class SomeObjectModel {

   @JsonProperty("task")
   State task;

   @JsonProperty("time")
   long time;

   @JsonProperty("bool")
   boolean bool;
}

Thanks 谢谢

You need to install Lombok in your IDE (based on your post tags seems that you are using Eclipse) 您需要在您的IDE中安装Lombok(基于您的帖子标记似乎您正在使用Eclipse)

Steps: 脚步:

  1. In your maven dependencies check your Lombok jar location (As alternative you can download the jar file directly from the Lombok web site ) Lombok location 在您的Maven依赖项中,检查您的Lombok jar位置(或者,您可以直接从Lombok网站下载jar文件) Lombok位置
  2. Close Eclipse 关闭Eclipse
  3. Open a command line where the Lombok jar file is located 打开Lombok jar文件所在的命令行
  4. Execute java -jar lombok-[VERSION].jar (An installation wizard will be opened) Installation wizard 执行java -jar lombok- [VERSION] .jar (将打开一个安装向导) 安装向导
  5. Out of the box the wizard will try to find your IDE installation, if the wizard doesn't find it, then you will have to provide the path 开箱即用的向导将尝试找到您的IDE安装,如果找不到该向导,则必须提供路径
  6. Click on "Install/Update" button 点击“安装/更新”按钮
  7. Close the installation wizard and open Eclipse 关闭安装向导并打开Eclipse
  8. Update your maven project Update project 更新您的Maven项目更新项目

I hope it helps!!! 希望对您有所帮助!!!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM