@Getter @Setter注释不能被解析为一个类型 [英] @Getter @Setter annotation cannot be resolved to a type
问题描述
我试图使自动化在我的JavaBean的getter和setter方法。
I am trying to automatize the getter and setter methods in my JavaBean.
一直以来,方法和域的命名约定豆类@ 命名约定描述,必须有使用这个惯例在为了避免锅炉板code如写getter和setter方法对每个bean的方法。我发现一个这样的方式这里。
Since, method and field naming conventions are described for Beans @ Naming Convention, there has to be a way to use this conventions in-order to avoid the boiler plate code such as writing getter and setter methods for every bean. I found one such way here.
我在我的Windows机器使用Eclipse IDE赫利俄斯与Java SE 6。虽然做的Eclipse提供了一种方法来生成getter和setter方法没有明确写他们,使用注释会使code更清洁和可读性。
I am using Eclipse Helios IDE with Java SE 6 in my Windows machine. Though Eclipse do provides a way to generate getter and setter methods without explicitly writing them, using annotations would make the code much more cleaner and readable.
然而,当我写了下面的code在我的Eclipse我得到以下错误@编译时:
However, when I write the following code in my Eclipse I get the following error @ Compile-time:
private @Getter @Setter int price;
错误:
消气不能被解析为一个类型。结果
二传手不能被解析为一个类型。
Getter cannot be resolved to a type.
Setter cannot be resolved to a type.
我如何解决这个问题?
推荐答案
@Getter
和 @Setter
不的Java的一部分。 项目龙目岛与这些名字注释,所以你应该看看如何设置它。
@Getter
and @Setter
are not part of Java. Project Lombok has annotations with these names, so you should look into how to set it up.
这篇关于@Getter @Setter注释不能被解析为一个类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!