JavaDoc @see for MyClass constructor returning a warning “reference not found”

霸气de小男生 提交于 2019-12-10 04:28:34

问题


I am trying to create javadoc for my client library. In MyOtherClass, I put the the below @see , and get warnings. MyOtherClass and MyClass both are in different packages, in the same project.

@see MyClass#Constructor(Type1 param1, Type2 param2)
warning - Tag @see: reference not found: MyClass#Constructor(Type1 param1, Type2 param2)

Then I tried

@see MyClass#MyClass(Type1 param1, Type2 param2) 
warning - Tag @see: reference not found: MyClass#MyClass(Type1 param1, Type2 param2)

Also tried

@see #MyClass(Type1 param1, Type2 param2)
warning - Tag @see: reference not found: MyOtherClass#MyClass(Type1 param1, Type2 param2)

I know I am missing something real silly here.


回答1:


This is because the Javadoc needs to know the exact location of the class you are referencing to create a link to it. Simply add the package as was mentioned in a comment above.

@see mypackage.MyClass#Constructor(Type1 p1, Type2 p2)

The javadoc tool will allow you to take shortcuts as follows:

// For methods in the same class:
@see #Constructor(Type1 p1, Type2 p2)

// For methods in the same package:
@see MyClass#Constructor(Type1 p1, Type2 p2)

If you have a long package name and want to hide it you can use a label:

@see mypackage.MyClass#Constructor(Type1 p1, Type2 p2) MyClass#Constructor(Type1 p1, Type2 p2)

The above will display:

See Also: MyClass.Constructor(Type1 p1, Type2 p2)

See the Oracle documentation here for more on @see


Warning: If you use the code completion feature of some IDEs (E.g. Eclipse) for creating Javadoc comments it may add an import for the package you are referencing instead. While this may make your comments look cleaner by excluding the package name it is not good practice to add actual dependencies purely for documentation.

来源:https://stackoverflow.com/questions/9970823/javadoc-see-for-myclass-constructor-returning-a-warning-reference-not-found

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!