Maven生成doc文档

本文介绍了如何使用Maven Javadoc插件生成Javadoc。在报告配置中添加插件可以将Javadoc包含在站点生成中,执行`mvn site`即可。若要生成独立的Javadoc,可将插件添加到构建部分,并通过执行不同目标命令来生成。Javadoc插件支持大量配置参数,详细信息可查阅官方文档。注意,<build>和<reporting>中的配置有不同的行为效果。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Usage

The Javadoc Plugin generates javadocs using the Javadoc tool. The following examples describe the basic usage of the Plugin.

Generate Javadocs As Part Of Project Reports

To generate javadocs as part of the site generation, you should add the Javadoc Plugin in the <reporting> section of your pom:

<project>
...
<reporting>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.8</version>
<configuration>
...
</configuration>
</plugin>
</plugins>
...
</reporting>
...
</project>
When you execute mvn site, the javadocs will be generated and included in the generated site. A link to the javadocs will be added in the Project Reports menu.


Generate Standalone Javadocs

To generate standalone javadocs for the project, you could add the Javadoc Plugin in the <build> section of your pom (if no configuration defined, the plugin uses default values):

<project>
...
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.8</version>
<configuration>
...
</configuration>
</plugin>
</plugins>
...
</build>
...
</project>
And execute any of the following commands:

mvn javadoc:javadoc
mvn javadoc:jar
mvn javadoc:aggregate
mvn javadoc:aggregate-jar
mvn javadoc:test-javadoc
mvn javadoc:test-jar
mvn javadoc:test-aggregate
mvn javadoc:test-aggregate-jar
For all jar goals, the javadocs are first generated and then packaged into a jar file.


Javadoc Configuration

The Javadoc Plugin supports a large number of configuration parameters. Each configuration parameter turns into a tag name.

Please refer to the Javadoc Plugin Documentation for a listing of these parameters. Most of these parameters are passed directly to the Javadoc tool itself.

IMPORTANT NOTE: configuring the Javadoc plugin in the <reporting/> or <build/> elements in the pom have NOT the same behavior as described in the Guide to Configuring Plug-ins.

For instance, if you have the following snippet:

<project>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.8</version>
<configuration>
<show>private</show>
<nohelp>true</nohelp>
</configuration>
</plugin>
</plugins>
</build>

<reporting>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.8</version>
<configuration>
<stylesheetfile>${basedir}/src/main/javadoc/stylesheet.css</stylesheetfile>
<show>public</show>
</configuration>
</plugin>
</plugins>
</reporting>
</build>mvn siteIt will generate the Javadoc for public members (defined in <reporting/>) using the given stylesheet (defined in <reporting/>), and with an help page (default value for nohelp is true).mvn javadoc:javadocIt will generate the Javadoc for private members (defined in <build/>) using the stylesheet (defined in <reporting/>), and with no help page (defined in <build/>).

参考页面:http://maven.apache.org/plugins/maven-javadoc-plugin/usage.html
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值