286

Currently I'm referencing methods in other classes with this Javadoc syntax:

@see {@link com.my.package.Class#method()}

And in what I understand from the documentation this is the correct way to do this. But now to the funny part, or frustrating. When I generate this javadoc I first of all get following error:

warning - Tag @see:illegal character: "123" in "{@link com.my.package.Class#method()}"
warning - Tag @see:illegal character: "64" in "{@link com.my.package.Class#method()}"
warning - Tag @see: reference not found: {@link com.my.package.Class#method()}

The Generated HTML code of this is:

"," <code>com.my.package.Class#method()}</code> ","

And of course I have no link. Can anyone tell me what's happening, and any hints on how to fix this?

According to the ASCII table characters 123 and 64 for wold represent { and @, so why aren't these characters valid when this syntax is correct according to the documentation?

4

3 回答 3

341

对于 Javadoc 标签@see,您不需要使用@link; Javadoc 将为您创建一个链接。尝试

@see com.my.package.Class#method()

这里有更多关于@see.

于 2013-07-05T19:57:39.580 回答
185

除此之外@see,引用另一个类和该类的可能方法的更一般的方法是{@link somepackage.SomeClass#someMethod(paramTypes)}. 这样做的好处是可以在 javadoc 描述的中间使用。

javadoc 文档(@link 标记的描述)

这个标签与@see 非常相似——两者都需要相同的引用并接受完全相同的 package.class#member 和 label 语法。主要区别在于 {@link} 生成内联链接,而不是将链接放在“另请参阅”部分。此外,{@link} 标记以花括号开头和结尾,以将其与内嵌文本的其余部分分开。

于 2014-10-23T15:28:27.280 回答
95

因此,原始问题的解决方案是您不需要在同一行上同时引用“@see”和“{@link...}”。“@link”标签是自给自足的,如前所述,您可以将它放在 javadoc 块中的任何位置。因此,您可以混合使用两种方法:

/**
 * some javadoc stuff
 * {@link com.my.package.Class#method()}
 * more stuff
 * @see com.my.package.AnotherClass
 */
于 2016-07-19T17:39:07.353 回答