linux sbt-1.1.0 安装

1.软件下载

  官网下载:https://www.scala-sbt.org/download.html 下载 sbt-1.1.0.tgz 包(目前最新)。

2.安装

   安装在/usr/local/sbt目录下

   

[root@master ~]# mv sbt-1.1.0.tgz /usr/local/
[root@master ~]#tar zxvf sbt-1.1.0.tgz 
[root@master local]# cd sbt


3.配置

   在/usr/local/sbt/目录下新建sbt文件,并添加如下内容:

[root@master sbt]# pwd
/usr/local/sbt
[root@master sbt]# vi sbt
SBT_OPTS="-Xms512M -Xmx1536M -Xss1M -XX:+CMSClassUnloadingEnabled -XX:MaxPermSize=256M"   #-XX:MaxPermSize=256M 在JAVA 1.8可以取消
java $SBT_OPTS -jar /usr/local/sbt/sbt-launch.jar "$@"    #将/usr/local/sbt/bin/下sbt-launch.jar拷贝到该目录或者直接指定
[root@master sbt]# chmod u+x sbt  #添加权限


配置仓库:

[root@master sbt]# vi ~/.sbt/repositories  #用户家目录下新建该文件,配置源,可以覆盖sbt-launch.jar 中的源
[repositories]
  local
  oschina: http://maven.oschina.net/content/groups/public/  
  #或者aliyun-nexus: http://maven.aliyun.com/nexus/content/groups/public/
  jcenter: http://jcenter.bintray.com/
  typesafe-ivy-releases: http://repo.typesafe.com/typesafe/ivy-releases/, [organization]/[module]/[revision]/[type]s/[artifact](-[classifier]).[ext], bootOnly
  maven-central: http://repo1.maven.org/maven2/


报错说明:

[root@master sbt]# ./sbt
java.lang.RuntimeException: Expected one of local, maven-local, maven-central, scala-tools-releases, scala-tools-snapshots, sonatype-oss-releases, sonatype-oss-snapshots, jcenter, got 'local  '.
at xsbti.Predefined.toValue(Predefined.java:28)
        at xsbt.boot.Repository$Predefined$.apply(LaunchConfiguration.scala:114)
        at xsbt.boot.ConfigurationParser$$anonfun$getRepositories$1.apply(ConfigurationParser.scala:197)
        at xsbt.boot.ConfigurationParser$$anonfun$getRepositories$1.apply(ConfigurationParser.scala:196)
        at scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:244)
        at scala.collection.immutable.List.foreach(List.scala:318)
        at org.apache.ivy.core.RelativeUrlResolver.map(RelativeUrlResolver.java:244)
        at scala.collection.AbstractTraversable.map(Traversable.scala:105)
        at xsbt.boot.ConfigurationParser.getRepositories(ConfigurationParser.scala:196)
        at xsbt.boot.ConfigurationParser$$anonfun$processRepositoriesConfig$1.apply(ConfigurationParser.scala:65)
        at xsbt.boot.ConfigurationParser$$anonfun$processSection$1.apply(ConfigurationParser.scala:109)
        at xsbt.boot.ConfigurationParser.process(ConfigurationParser.scala:110)
        at xsbt.boot.ConfigurationParser.processSection(ConfigurationParser.scala:109)
        at xsbt.boot.ConfigurationParser.xsbt$boot$ConfigurationParser$$readRepositoriesConfig(ConfigurationParser.scala:63)
        at xsbt.boot.ConfigurationParser$$anonfun$readRepositoriesConfig$2.apply(ConfigurationParser.scala:59)
        at xsbt.boot.Using$.withResource(Using.scala:10)
        at xsbt.boot.Using$.apply(Using.scala:9)
        at xsbt.boot.ConfigurationParser$$anonfun$readRepositoriesConfig$1.apply(ConfigurationParser.scala:57)
        at xsbt.boot.Using$.withResource(Using.scala:10)
        at xsbt.boot.Using$.apply(Using.scala:9)
        at xsbt.boot.ConfigurationParser$$anonfun$10.apply(ConfigurationParser.scala:79)
        at scala.Option.map(Option.scala:145)
        at xsbt.boot.ConfigurationParser.xsbt$boot$ConfigurationParser$$app
......
在配置vi ~/.sbt/repositories 时每行都是以换行结尾,上面配置local后有空格。。。

4.验证

  执行新建文件/usr/local/sbt/sbt,会根据配置的源下载依赖包如下:

[root@master sbt]# ./sbt            
Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=256M; support was removed in 8.0
Getting org.scala-sbt sbt 1.1.0  (this may take some time)...
downloading http://jcenter.bintray.com/org/scala-sbt/logic_2.12/1.1.0/logic_2.12-1.1.0.jar ...
        [SUCCESSFUL ] org.scala-sbt#logic_2.12;1.1.0!logic_2.12.jar (1614ms)
downloading http://jcenter.bintray.com/org/scala-sbt/actions_2.12/1.1.0/actions_2.12-1.1.0.jar ...
        [SUCCESSFUL ] org.scala-sbt#actions_2.12;1.1.0!actions_2.12.jar (2579ms)
downloading http://jcenter.bintray.com/org/scala-sbt/main-settings_2.12/1.1.0/main-settings_2.12-1.1.0.jar ...
        [SUCCESSFUL ] org.scala-sbt#main-settings_2.12;1.1.0!main-settings_2.12.jar (3564ms)
下载过程中可能有些包下载失败,网络原因或者源问题等,重新执行该命令,或者换源试试,有可能这些包不常用,没下载到也不影响使用。阿里源:aliyun-nexus: http://maven.aliyun.com/nexus/content/groups/public/ (修改上面的oschina)

看到如下信息已经安装成功:

[info] Set current project to sbt (in build file:/usr/local/sbt/)
[info] sbt server started at local:///root/.sbt/1.0/server/c7ce02f6552ee029436f/sock
sbt:sbt> 

配置系统环境变量:

[root@master sbt]# vi /etc/profile
export SBT_HOME=/usr/local/sbt/    #添加变量SBT_HOME
export PATH=$PATH:$HADOOP_HOME/bin:$JAVA_HOME/bin:$HBASE_HOME/bin:$HIVE_HOME/bin:$SQOOP_HOME/bin:$SBT_HOME/
[root@master bin]# source  /etc/profile  #生效




你可能感兴趣的:(Linux)