简体   繁体   English

如何更改Java注释模板?

[英]How to change Java comments template?

I use /** + ENTER to generate javadoc, but i found there's a whitespace before line 3: 我使用/ ** + ENTER生成javadoc,但是我发现在第3行之前有一个空格:

1 /**
2 * Test.
3 * 
4 * @author xxx
5 */

Every time i try "source - format" in eclipse,the white space comes out. 每次我在Eclipse中尝试“源-格式”时,都会出现空白。 How can i remove this whitespace in the comments template somewhere ? 我如何在某处的注释模板中删除此空白?

I have option Blank line before Javadoc tags in preference->Java->Code style->Formater, click on Edit button, open Comments tab and look at Javadoc comment settings . 我在Preferences-> Java-> Code style-> Formater中的Javadoc标记之前有选项Blank行 ,单击Edit按钮,打开Comments选项卡,然后查看Javadoc注释设置 May be it helps you. 可能对您有帮助。

This has been pissing me off for some time until I finally found the solution . 这让我很生气,直到我终于找到解决方案 He mentions this is work around, it does not matter for me - it works like a charm. 他提到这是可以解决的,对我而言并不重要-它就像一种魅力。 Don't forget to plus him, he is life savior! 别忘了加他,他是生命的救星!

You may need to turn off Javadoc comment formatting completely. 您可能需要完全关闭Javadoc注释格式。

Since Javadoc comments get turned into HTML with the default Javadoc generator/snippet, it doesn't care about extra spaces, or line breaks. 由于Javadoc注释已使用默认的Javadoc生成器/代码段转换为HTML,因此它不会在意多余的空格或换行符。 One whitespace character is the same as many. 一个空格字符与许多空格字符相同。

This is reflected by the Eclipse Javadoc formatter, which will treat it as a piece of markup which can be completely reformatted, so long as the output looks the same to Javadoc. Eclipse Javadoc格式化程序反映了这一点,只要将输出与Javadoc看起来相同,它将视为完全可以重新格式化的标记。 I can't see any way to change the options to preserve that whitespace without turning off the formatting altogether. 在完全不关闭格式的情况下,我看不到任何更改选项以保留该空白的方法。

您可以在Eclipse-> preference-> Java-> Code style-> Code Templates-> Types中进行设置,然后进行编辑,并可以插入日期,时间等变量。

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

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