Maven build plugin failed with official document

Refs to

I build my project with maven, and the pom.xml is the following:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns=""





And I run mvn package with this pom.xml, it shows some error message:

[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Building audit 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] --- maven-enforcer-plugin:1.4.1:enforce (enforce-versions) @ audit ---
[INFO] --- maven-enforcer-plugin:1.4.1:enforce (enforce-maven-version) @ audit ---
[INFO] --- maven-enforcer-plugin:1.4.1:display-info (print-versions) @ audit ---
[INFO] Maven Version: 3.3.9
[INFO] JDK Version: 1.8.0_151 normalized as: 1.8.0-151
[INFO] OS Info: Arch: x86_64 Family: mac Name: mac os x Version: 10.12.6
[INFO] --- maven-enforcer-plugin:1.4.1:enforce (enforce-java-home-is-set) @ audit ---
[WARNING] Rule 0: org.apache.maven.plugins.enforcer.RequireEnvironmentVariable failed with message:
"JAVA_HOME must be set and point to the jdk to run the tests"
[INFO] ------------------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.944 s
[INFO] Finished at: 2017-11-21T11:34:00+08:00
[INFO] Final Memory: 20M/309M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-enforcer-plugin:1.4.1:enforce (enforce-java-home-is-set) on project audit: Some Enforcer rules have failed. Look above for specific messages explaining why the rule failed. -> [Help 1]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1]

but I already set $JAVA_HOME before.

➜  ~ echo $JAVA_HOME
➜  ~ which java
➜  ~ which javac

How to resolve this issue ? I found another same issue here but there is no answer.

Find the answer, Idea does not read the env variable correctly, use launchctl setenv JAVA_HOME /Library/Java/JavaVirtualMachines/jdk1.8.0_151.jdk/Contents/Home could fix it.

Please close this issue. Thanks

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.