用龙目岛创建枚举 [英] Creating enums with lombok

查看:93
本文介绍了用龙目岛创建枚举的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的应用程序中使用了lombok项目.我正在创建一个枚举.如果我使用

I am using project lombok with my application. I was creating an enum. If I use

@AllArgsConstructor

@AllArgsConstructor

使用我的枚举进行批注,它无法识别构造函数,枚举抛出并且无法接受字符串参数的错误.

annotation with my enum, it doesn't recognise the constructor, enum throws and error that it cannot take string argument.

该如何解决?

import lombok.Getter;
import lombok.AllArgsConstructor

@AllArgsConstructor
public enum Direction {
    NORTH("NORTH"), // all these enums give error, for no constructor
    SOUTH("SOUTH"),
    EAST("EAST"),
    WEST("WEST");

    @Getter private String value;
}

P.S .:我正在使用具有lombok插件安装的intellij-idea.我的龙目岛依赖版本是:1.16.20

P.S.: I am using intellij-idea, which has lombok plugin install. My lombok dependency version is: 1.16.20

推荐答案

您还必须在设置"->构建"->编译器"->注释处理器"中启用启用注释处理"

You also have to have enabled "Enable annotation processing" in Settings -> Build -> Compiler -> Annotation Processor

这篇关于用龙目岛创建枚举的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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