*本文针对Mac下的开发环境配置
1.安装java
Mac自带了的JDK6,安装在目录:/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/下.自己安装的JDK默认路径为:/Library/Java/JavaVirtualMachines/.
java9和scala2.11会有兼容性的问题,所以要设置为java8.
2.安装scala
spark用的还是scala 2.11,所以安装了scala 2.11和2.12 ,要把当前版本设置为2.11
3.设置环境变量
在'~/.bash_profile'文件中添加如下内容
export SCALA_HOME=/opt/scala/scala-2.11.12
export PATH=$PATH:$SCALA_HOME/bin
export JAVA_9_HOME=/Library/Java/JavaVirtualMachines/jdk-9.0.1.jdk/Contents/Home
export JAVA_8_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_151.jdk/Contents/Home
export JAVA_HOME=$JAVA_8_HOME
装了zsh的话就在~/.zshrc中添加同样的内容
4.安装本地sbt
➜ ~ brew install sbt@1
Updating Homebrew...
==> Downloading https://github.com/sbt/sbt/releases/download/v1.0.3/sbt-1.0.3.tgz
==> Downloading from https://github-production-release-asset-2e65be.s3.amazonaws.com/279553/d3e64dba-baad-11e7-972d-9974d629917f?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIW
######################################################################## 100.0%
==> Caveats
You can use $SBT_OPTS to pass additional JVM options to SBT:
SBT_OPTS="-XX:+CMSClassUnloadingEnabled -XX:MaxPermSize=256M"
This formula uses the standard Lightbend sbt launcher script.
Project specific options should be placed in .sbtopts in the root of your project.
Global settings should be placed in /usr/local/etc/sbtopts
==> Summary
? /usr/local/Cellar/sbt/1.0.3: 494 files, 73.8MB, built in 23 seconds
➜ ~
5.添加全局镜像库
在'~/.sbt/'下添加一个'repositories'文件,里面内容如下:
[repositories]
local
aliyun: http://maven.aliyun.com/nexus/content/groups/public/
aliyun-ivy:http://maven.aliyun.com/nexus/content/groups/public/, [organization]/[module]/(scala_[scalaVersion]/)(sbt_[sbtVersion]/)[revision]/[type]s/[artifact](-[classifier]).[ext], bootOnly
typesafe:http://dl.bintray.com/typesafe/ivy-releases/ , [organization]/[module]/(scala_[scalaVersion]/)(sbt_[sbtVersion]/)[revision]/[type]s/[artifact](-[classifier]).[ext], bootOnly
typesafe-ivy-releases: https://repo.typesafe.com/typesafe/ivy-releases/, [organization]/[module]/[revision]/[type]s/[artifact](-[classifier]).[ext], bootOnly
ivy-sbt-plugin:http://dl.bintray.com/sbt/sbt-plugin-releases/, [organization]/[module]/(scala_[scalaVersion]/)(sbt_[sbtVersion]/)[revision]/[type]s/[artifact](-[classifier]).[ext]
sonatype-oss-releases
maven-central
sonatype-oss-snapshots
参考: