javadoc annotations and maven-javadoc-plugin plug-in

1. javadoc annotation tags:
  • @author: author-class, interface level

  • @version: version-class, interface level

  • @deprecated: Deprecated method

  • @param: parameters of methods and constructors

  • @return: the return type of the method

  • @see: used to specify reference content, usually with links or text entries

  • @exception: exception thrown

  • @throws: Exception thrown, synonymous with exception

  • @since: Identifies the version and time specified by this change or feature.

2. maven-javadoc-plugin plug-in
                    <!-- 生成API文档插件 -->
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-javadoc-plugin</artifactId>
                        <version>3.3.2</version>
                        <executions>
                            <execution>
                                <id>attach-javadocs</id>
                                <goals>
                                    <goal>jar</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>

When packaging in a java project, the maven-javadoc-plugin plug-in will be introduced to package the java annotations into a jar package. However, if the java annotations are not standard enough, an exception will be thrown and normal packaging will not be possible. The following exception:

Command line was: /Library/Java/JavaVirtualMachines/jdk-11.0.10.jdk/Contents/Home/bin/javadoc @options @packages

Refer to the generated Javadoc files in '/Users/xx/Documents/IDE/workplace-java/spring-parent/emily-spring-boot-logger/target/apidocs' dir.

Solution: Add the failOnError parameter to control whether to stop the build if an error occurs during the build process, as configured below:

                    <!-- 生成API文档插件 -->
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-javadoc-plugin</artifactId>
                        <version>3.3.2</version>
                        <configuration>
                            <failOnError>false</failOnError>
                        </configuration>
                        <executions>
                            <execution>
                                <id>attach-javadocs</id>
                                <goals>
                                    <goal>jar</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>

Set the failOnError parameter to false, which will not stop the build process if an error occurs while generating the documentation.

3. Exclude the specified package and check whether the javadoc document is correct during the construction process.

You can specify which packages or annotations to exclude through the excludePackageNames parameter.

                        <configuration>
                            <!--控制构建过程中如果出现错误是否停止构建-->
                            <failOnError>false</failOnError>
                            <!--排除指定的包,可以使用: or , or ; 三种符号分割-->
                            <excludePackageNames>com.emily.cloud.test.*,com.emily.infrastructure.test.*</excludePackageNames>
                        </configuration>

GitHub address: https://github.com/mingyang66/spring-parent

Guess you like

Origin blog.csdn.net/yaomingyang/article/details/131966926