如何防止仅出于快速修复serialVersionUID警告而自动生成注释? [英] How to prevent the auto-generation of comments just for quick-fixing the serialVersionUID warning?

查看:89
本文介绍了如何防止仅出于快速修复serialVersionUID警告而自动生成注释?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这个Eclipse问题是对的响应eclipse上方的注释会生成serialVersionUID, ,但到目前为止,单个答案(解决了此链接的问题并被接受)适用于所有注释。



但是我的问题会更具体(它不是重复的)-我希望正常生成其他字段的注释,而在通过生成字段快速修复可序列化警告时仅不生成注释。



作为对原始问题的公认答案,回答者表示


它正在使用任何月蚀生成字段的模板。



您可以在

中进行更改首选项-> 
Java->
代码样式->
代码模板->
评论->
字段


然后清空模式。 / p>

尽管您可以阻止所有字段的注释生成(或更改注释模板),但是有什么方法可以阻止或更改自动注释生成 / em> serialVersionUID 字段?

解决方案


$ b $的一种方法,可以通过快速修复来防止为 SerialVersionUID 自动生成注释,而不会空白所有字段的注释生成模板。



尽管如此,没关系,因为按照原始问题中的说明简单地将注释模板空白就足够了,因为自动生成仅适用于范围很窄的场景,包括-fix。



通常是从工具栏中或通过右键单击字段从源中生成元素注释时生成注释模板。 d,而这完全是可选的。


This Eclipse question is a response to "Getting rid of the comment above eclipse generated serialVersionUID," but so far the single answer (which addresses this linked question, and is accepted) applies to all comments.

But my question will be more specific (it is not a duplicate) - I want normal generation of comments for other fields, just no generation of the comment when you quick-fix the serializable warning by generating the field.

As what the accepted answer to the original question, the answerer stated that

It's using the template for any eclipse-generated field.

You can change it in

 Preferences -> 
     Java -> 
        Code Style -> 
           Code Templates -> 
              Comments -> 
                 Fields

and then blank out the pattern.

Though you can prevent comment generation (or change the comment template) for all fields, is there any way to prevent or change auto-comment-generation just for the serialVersionUID field?

解决方案

There isn't a way to prevent the auto-generation of comments for the SerialVersionUID through quick-fixing without blanking the comment generation template for all fields.

Nevertheless, it doesn't matter as simply blanking the comment template as addressed in the original question is sufficient, as the auto-generation applies to a very narrow range of scenarios, including this quick-fix.

The comment template is normally generated when you generate element comment from the Source either from the toolbar or by right-clicking the field, and that is entirely optional.

这篇关于如何防止仅出于快速修复serialVersionUID警告而自动生成注释?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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