一、JDK配置
1. 系统默认
(1)mac中有自带JDK配置,具体查看命令如下:
$ whereis java
/usr/bin/java
$ ls -l /usr/bin/java
lrwxr-xr-x 1 root wheel 74 9 22 23:32 /usr/bin/java -> /System/Library/Frameworks/JavaVM.framework/Versions/Current/Commands/java
2. 自己配置
(1)下载对应JDK(默认安装目录为 /Library/Java/JavaVirtualMachines/ )
(2)执行 vi ~/.bash_profile 。插入以下代码:
export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_231.jdk/Contents/Home
export PATH=.:~:$JAVA_HOME/bin
(4)执行source ~/.bash_profile命令
(5)验证JAVA_HOME目录是否配置正确
$ echo $JAVA_HOME
Library/Java/JavaVirtualMachines/jdk1.8.0_231.jdk/contents/home
(6)判断是否已经配置成功。
$ java -version
java version"1.8.0_231"Java(TM)SERuntimeEnvironment(build1.8.0_231-b14)
JavaHotSpot(TM)64-BitServerVM(build25.92-b14,mixed mode)
二、 maven 配置
1. 下载安装包
官网:https://maven.apache.org/download.cgi
2. 将下载的文件解压然后直接拖入终端获取文件的地址 '/usr/local'
3.(1)打开终端输入 vim ~/.bash_profile
export M2_HOME='url' (这个url就是maven文档解压放的地址)
export M2=$M2_HOME/bin
export PATH=$M2:$PATH
(2)在终端输入 source ~/.bash_profile 使环境变量生效
(3)在终端输入 mvn -v
$ mvn -v
Apache Maven 3.6.2 (40f52333136460af0dc0d7232c0dc0bcf0d9e117; 2019-08-27T23:06:16+08:00)
Maven home: /usr/local/Cellar/maven/3.6.2/libexec
Java version: 1.8.0_231, vendor: Oracle Corporation, runtime: /Library/Java/JavaVirtualMachines/jdk1.8.0_231.jdk/Contents/Home/jre
Default locale: zh_CN, platform encoding: UTF-8
OS name: "mac os x", version: "10.14.6", arch: "x86_64", family: "mac"
恭喜你,已经配置好了!
参考:
链接:https://www.jianshu.com/p/cb8789ab1249
链接:https://blog.csdn.net/qq_31774257/article/details/81048821