【问题标题】:Javadoc - multiline comment with annotation (@ sign)Javadoc - 带注释的多行注释(@ 符号)
【发布时间】:2013-12-15 18:51:08
【问题描述】:

基于答案:Multiple line code example in Javadoc comment 我想编写以下 javadoc(在类级别)。

/**
 * Whatever txt1 ...
 * <pre>
 * {@code
 *  @Lob
 *  private byte[] foo;
 * }
 * </pre>
 * Whatever txt2 ...
 * 
 * @author $Author: $
 */
public class Foo {

但是它呈现这样(在 Eclipse 预览中):

Whatever txt1 ...


Author:
 $Author: $
@Lob
private byte[] foo;
 }

Whatever txt2 ...

请注意作者注释的乱序

知道什么是适当的格式/如何正确转义@ 符号吗?

一如往常:

/**
 * Whatever txt1 ...
 * <pre>
 * {@code
 *  Lob
 *  private byte[] foo;
 * }
 * </pre>
 * Whatever txt2 ...
 * 
 * @author $Author: $
 */
public class Foo {

渲染正确:

Whatever txt1 ...

Lob
 private byte[] foo;

 Whatever txt2 ...
 Author:
 $Author: $

【问题讨论】:

标签: annotations javadoc


【解决方案1】:

好的,我在其他地方找到了答案:https://stackoverflow.com/questions/2290757/how-can-you-escape-the-character-in-javadoc

问题是{@literal @}

那么:

/**
 * Whatever txt1 ...
 * <pre>
 * {@code
 *  {@literal @}Lob
 *  private byte[] foo;
 * }
 * </pre>
 * Whatever txt2 ...
 * 
 * @author $Author: $
 */
public class Foo {

正确呈现给:

Whatever txt1 ...


{@Lob
private byte[] foo;
}

Whatever txt2 ...
Author:
$Author: $

【讨论】:

    【解决方案2】:

    因为您参考了多行代码示例线程: 此线程中的以下答案有您的示例 - 转义“@Override”上的“@”符号 https://stackoverflow.com/a/13512524

    问候 克里斯托弗

    【讨论】:

    • 如果这实际上是重复的,您应该将其标记为这样,而不是将其发布为答案。
    猜你喜欢
    • 2016-07-19
    • 2015-11-02
    • 2010-10-07
    • 2014-01-15
    • 2011-02-07
    • 2017-03-22
    • 2012-03-17
    • 2012-05-08
    相关资源
    最近更新 更多