一、pom.xml 添加插件
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>3.1.1</version>
<configuration>
<show>private</show>
<nohelp>true</nohelp>
<charset>UTF-8</charset>
<encoding>UTF-8</encoding>
<docencoding>UTF-8</docencoding>
<doclint>none</doclint>
<tags>
<tag>
<!-- 处理@date标签 -->
<name>date</name>
<placement>a</placement>
</tag>
</tags>
</configuration>
<executions>
<execution>
<phase>compile</phase>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
二、问题解决
错误内容
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-javadoc-plugin:3.1.1:jar (default) on project slog-core: MavenReportException: Error while generating Javadoc:
[ERROR] Exit code: 1 - javadoc: 错误 - 进行文档化的代码使用了模块,但在 https://docs.oracle.com/javase/8/docs/api/ 中定义的程序包在未命名模块中。
[ERROR]
[ERROR] Command line was: "D:\Program Files\Java\jdk-13.0.2\bin\javadoc.exe" @options @packages
[ERROR]
[ERROR] Refer to the generated Javadoc files in 'F:\IntelliJProject\snail-log\slog-core\target\apidocs' dir.
后来发现是jdk版本配置问题,本机安装的jdk版本为jdk13,项目配置的版本为1.8,平时使用不会有异常,但是javadoc打包即会报错。
修改pom.xml后内容如下,版本替换为当前使用的版本即可。
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>13</source>
<target>13</target>
</configuration>
</plugin>
</plugins>
</build>