MavenReportException:The environment variable JAVA_HOME is not correctly set.错误异常解决方法

时间:2021-05-23 22:58:37

用Maven打包带javadoc项目,提示错误信息如下:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-javadoc-plugin:2.7:jar 
(attach-javadocs) on project api: MavenReportException:
Error while creating archive:Unable to find javadoc command:
The environment variable JAVA_HOME is not correctly set. -> [Help 1]

出现这个问题,是因为 JAVA_HOME指向了JRE而不是JDK:

MavenReportException:The environment variable JAVA_HOME is not correctly set.错误异常解决方法

所以解决办法是在maven javadoc插件中手动配置:

 
<javadocExecutable>${java.home}/../bin/javadoc</javadocExecutable>

如下: