A pit of Maven in OSX
Maven in OSX system is basically installed by homebrew. Maven is written in Java and needs JRE running environment. So homebrew will automatically install openjdk for you
{
"homebrew_version":"2.4.0-69-g67c843b-dirty",
"used_options":[
],
"unused_options":[
],
"built_as_bottle":false,
"poured_from_bottle":false,
"installed_as_dependency":false,
"installed_on_request":true,
"changed_files":null,
"time":1592835968,
"source_modified_time":1573129938,
"HEAD":"67c843b91ef272d5408fc2cb74ce8b39042ec1bf",
"stdlib":null,
"compiler":"clang",
"aliases":[
"[email protected]"
],
"runtime_dependencies":[
{
"full_name":"openjdk",
"version":"13.0.2+8"
}
],
"source":{
"path":"/usr/local/Homebrew/Library/Taps/homebrew/homebrew-core/Formula/maven.rb",
"tap":"homebrew/core",
"spec":"stable",
"versions":{
"stable":"3.6.3",
"devel":"",
"head":"",
"version_scheme":0
}
}
}****
Most of the time, it’s safe until we meet javax.xml.bind.annotationPackage. This package exists in jdk8 and is removed in jdk11. Therefore, the following problems occur in MVN package
At first, I thought there was something wrong with the POM file configuration. Later, I found that Maven with idea can be compiled, so the code should be empty. So I checked the Maven version. There was a problem
you ‘re right ,[email protected] Openjdk13.0 will be automatically installed as a dependency during the installation. Obviously, it conflicts with our development environment 1.8. Change it decisively
As follows, Java_ Change home to our JDK1.8
#!/bin/bash
JAVA_HOME="${JAVA_HOME:-/Library/Java/JavaVirtualMachines/jdk1.8.0_251.jdk/Contents/Home}" exec "/usr/local/Cellar/maven/3.6.3_1/libexec/bin/mvn" "[email protected]"
Execute MVN package again. Compile successfully