macos maven installation steps and problem solutions

First, you must install jdk and configure the java environment variables.

Command 1: whereis java
/usr/bin/java
Command 2: ls -l /usr/bin/java
lrwxr-xr-x 1 root wheel 74 10 20 23:35 /usr/bin/java -> /System/Library/Frameworks/JavaVM.framework/Versions/Current/Commands/java

Command 3: vi ~/.bash_profile (fill in the content jdk version number can be modified according to your own version)
JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk 1.8.0_144 .jdk/Contents/Home
CLASSPAHT=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
PATH=$JAVA_HOME/bin:$PATH:
export JAVA_HOME
export CLASSPATH
export PATH
M2_HOME=/Users/liushahe/java/apache-maven-3.5.3;
export M2_HOME
export PATH=$PATH:$M2_HOME/bin

Command 4: source /.bash_profile
The problem encountered: The name of the environment variable used in the first installation is MAVEN_HOME. But my local MAVEN version is 3.0+, and M2_HOME must be used. After modification, execute the command mvn -v to display normal information.



Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325858607&siteId=291194637