这是预期的,javadoc只复制来自源路径内的类的注释.从
Method Comment Inheritance开始:
Note: The source file for an inherited method must be on the path specified by the -sourcepath option for the documentation comment to be available to copy. Neither the class nor its package needs to be passed in on the command line. This contrasts with Release 1.3.n and earlier releases, where the class had to be a documented class.
Inheriting Comments from J2SE – Your code can also automatically inherit comments from interfaces and classes in the J2SE. You can do this by unzipping the src.zip file that ships with the SDK (it does not contain all source files, however), and add its path to -sourcepath. When javadoc runs on your code, it will load the doc comments from those source files as needed. For example, if a class in your code implements java.lang.Comparable, the compareTo(Object) method you implement will inherit the doc comment from java.lang.Comparable.
所以,要使它工作:
>找到JDK的源代码并将其解压缩到某处.
>配置maven-javadoc-plugin以使用sourcepath参数添加这些源.
>通过上面的内容,我们还将生成JDK本身的Javadoc,这是不必要的(我们只想继承),因此我们可以使用subpackages来仅指定我们的包.或者,我们可以使用excludePackageNames来排除JDK包.
> JDK(至少Oracle JDK)也使用新的Javadoc条目,即@ apiNote,@ implSpec和@implNote.这些是需要使用tags参数添加的自定义标记.
这是一个示例配置,其中JDK源的路径是/ path / to / jdk / sources(您还可以使用环境变量,由配置文件设置的属性等),并且您自己的源文件都在我的包中.包:
org.apache.maven.plugins
maven-javadoc-plugin
2.10.1
/path/to/jdk/sources:${basedir}/src/main/java
my.package
apiNote
a
implSpec
a
implNote
a
生成Javadoc,例如使用mvn javadoc:javadoc,将正确解析{@inheritDoc}.