使用javadoc生成API文档
一、使用idea工具辅助生成javadoc文档
zh_CN
-encoding utf-8 -charset utf-8 -tag date:a:"日期:" -doctitle "示例" -windowtitle "示例"
idea 开发工具 Tools->Generate JavaDoc
二、使用maven-javadoc-plugin辅助生成javadoc文档
1.单模块项目
<profiles>
<profile>
<id>javadoc</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<configuration>
<encoding>utf-8</encoding>
<docencoding>utf-8</docencoding>
<charset>utf-8</charset>
<tags>
<tag>
<name>date</name>
<placement>a</placement>
<head>日期:</head>
</tag>
</tags>
<doctitle>示例</doctitle>
<windowtitle>示例</windowtitle>
<locale>zh_CN</locale>
<doclint>all,-missing</doclint>
</configuration>
<executions>
<execution>
<id>attach-javadocs</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>source</id>
<build>
<plugins>
<plugin>
<artifactId>maven-source-plugin</artifactId>
<configuration>
<attach>true</attach>
</configuration>
<executions>
<execution>
<id>attach-source</id>
<goals>
<goal>jar-no-fork</goal>
</goals>
<phase>package</phase>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
若生成javadoc过程中,控制台出现乱码,可尝试以下操作: -Dfile.encoding=GBK
2.多模块项目
<profiles>
<profile>
<id>javadoc</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<inherited>false</inherited>
<configuration>
<encoding>utf-8</encoding>
<docencoding>utf-8</docencoding>
<charset>utf-8</charset>
<tags>
<tag>
<name>date</name>
<placement>a</placement>
<head>日期:</head>
</tag>
</tags>
<doctitle>示例</doctitle>
<windowtitle>示例</windowtitle>
<locale>zh_CN</locale>
<doclint>all,-missing</doclint>
<excludePackageNames>com.example.package1:com.example.package1.*</excludePackageNames>
</configuration>
<executions>
<execution>
<id>aggregate</id>
<goals>
<goal>aggregate-jar</goal>
</goals>
<phase>package</phase>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>source</id>
<build>
<plugins>
<plugin>
<artifactId>maven-source-plugin</artifactId>
<configuration>
<attach>true</attach>
</configuration>
<executions>
<execution>
<id>attach-source</id>
<goals>
<goal>jar-no-fork</goal>
</goals>
<phase>package</phase>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
建议启用 use plugin registry
3.生成javadoc
多模块项目root下,执行生命周期阶段clean 和package
mvn clean package
参考: 使用javadoc命令生成多个包的doc文档 JavaDoc的使用详解
|