Java 在Eclipse中为getter和setter自动生成注释

Java 在Eclipse中为getter和setter自动生成注释,java,eclipse,ide,comments,getter-setter,Java,Eclipse,Ide,Comments,Getter Setter,Eclipse可以选择从各自的变量生成getter和setter。是否有一个选项或设置,我也可以通过它为getter和setter生成注释 e、 g.如果我的变量名是 protected boolean isActive; 那么,当我为这个生成getter时,我也可以像这样得到自动生成的注释块吗- /** * Gets the value of the isActive property. * * @return * possible object is * {@l

Eclipse可以选择从各自的变量生成getter和setter。是否有一个选项或设置,我也可以通过它为getter和setter生成注释

e、 g.如果我的变量名是

protected boolean isActive;
那么,当我为这个生成getter时,我也可以像这样得到自动生成的注释块吗-

/**
 * Gets the value of the isActive property.
 * 
 * @return
 *     possible object is
 *     {@link Boolean }
 *     
 */
public Boolean getIsActive() {
    return isActive;
}

如果这件事有可能,那就太好了。注释块也是可自定义的吗?

转到首选项>Java>代码样式>代码模板,然后更改注释>Getters模板。您还需要确保选中“自动为新方法和类型添加注释”复选框

虽然可以通过首选项修改默认模板来实现这一点,但这不过分,因为getter的注释除了在少数情况下不会增加任何价值吗?是的。但当客户愚蠢地理解这一点时,你也无能为力或者您可以使用:无需生成更多注释;)