1. 程式人生 > >Idea配置sbt(window環境)

Idea配置sbt(window環境)

開發環境:windows

1. 下載sbt

http://www.scala-sbt.org/download.html

我使用的是zip包,下載後解壓到d:\tool\目錄

2.新增配置

2.1 開啟D:\tool\sbt\conf\sbtconfig.txt,在最後新增下面幾行配置,注意指定的目錄和檔案

-Dsbt.ivy.home=D:/tool/sbt/.ivy2
-Dsbt.global.base=D:/tool/sbt/.sbt
-Dsbt.repository.config=D:/tool/sbt/conf/repo.properties

 第一行sbt.ivy.home指定了本地自定義的repository路徑(如果不設定就是預設的使用者目錄C:\Users\Administrator\.ivy2)

2.2 在D:/tool/sbt/conf/目錄下新建repo.properties檔案,填寫下面內容,指定映象站的地址:

複製程式碼 [repositories]   local   comp-maven:http://mvnrepository.com/artifact/   store_cn:http://maven.oschina.net/content/groups/public/   store_mir:http://mirrors.ibiblio.org/maven2/   store_0:http://maven.net.cn/content/groups/public/   store_1:http://repo.typesafe.com/typesafe/ivy-releases/   store_2:http://repo2.maven.org/maven2/   sbt-releases-repo: http://repo.typesafe.com/typesafe/ivy-releases/, [organization]/[module]/(scala_[scalaVersion]/)(sbt_[sbtVersion]/)[revision]/[type]s/[artifact](-[classifier]).[ext]   sbt-plugins-repo: http://repo.scala-sbt.org/scalasbt/sbt-plugin-releases/, [organization]/[module]/(scala_[scalaVersion]/)(sbt_[sbtVersion]/)[revision]/[type]s/[artifact](-[classifier]).[ext]   maven-central: http://repo1.maven.org/maven2/
複製程式碼 請確保一定要增加高亮部分,否則會出現如下錯誤, 最後把路徑D:\sbt\bin 新增到Path中。 D:\work\scala\sbt\bin>sbt.bat Getting org.scala-sbt sbt 0.13.9 ... :: problems summary :: :::: WARNINGS                 module not found: org.scala-sbt#sbt;0.13.9         ==== local: tried           D:\work\scala\sbt\.ivy2\local\org.scala-sbt\sbt\0.13.9\ivys\ivy.xml           -- artifact org.scala-sbt#sbt;0.13.9!sbt.jar:           D:\work\scala\sbt\.ivy2\local\org.scala-sbt\sbt\0.13.9\jars\sbt.jar         ==== comp-maven: tried           http://mvnrepository.com/artifact/org/scala-sbt/sbt/0.13.9/sbt-0.13.9.pom           -- artifact org.scala-sbt#sbt;0.13.9!sbt.jar:           http://mvnrepository.com/artifact/org/scala-sbt/sbt/0.13.9/sbt-0.13.9.jar         ==== store_cn: tried           http://maven.oschina.net/content/groups/public/org/scala-sbt/sbt/0.13.9/sbt-0.13.9.pom           -- artifact org.scala-sbt#sbt;0.13.9!sbt.jar:           http://maven.oschina.net/content/groups/public/org/scala-sbt/sbt/0.13.9/sbt-0.13.9.jar         ==== store_mir: tried           http://mirrors.ibiblio.org/maven2/org/scala-sbt/sbt/0.13.9/sbt-0.13.9.pom           -- artifact org.scala-sbt#sbt;0.13.9!sbt.jar:           http://mirrors.ibiblio.org/maven2/org/scala-sbt/sbt/0.13.9/sbt-0.13.9.jar         ==== store_0: tried           http://maven.net.cn/content/groups/public/org/scala-sbt/sbt/0.13.9/sbt-0.13.9.pom           -- artifact org.scala-sbt#sbt;0.13.9!sbt.jar:           http://maven.net.cn/content/groups/public/org/scala-sbt/sbt/0.13.9/sbt-0.13.9.jar         ==== store_1: tried           http://repo.typesafe.com/typesafe/ivy-releases/org/scala-sbt/sbt/0.13.9/sbt-0.13.9.pom           -- artifact org.scala-sbt#sbt;0.13.9!sbt.jar:           http://repo.typesafe.com/typesafe/ivy-releases/org/scala-sbt/sbt/0.13.9/sbt-0.13.9.jar         ==== store_2: tried           http://repo2.maven.org/maven2/org/scala-sbt/sbt/0.13.9/sbt-0.13.9.pom           -- artifact org.scala-sbt#sbt;0.13.9!sbt.jar:           http://repo2.maven.org/maven2/org/scala-sbt/sbt/0.13.9/sbt-0.13.9.jar                 ::::::::::::::::::::::::::::::::::::::::::::::                 ::          UNRESOLVED DEPENDENCIES         ::                 ::::::::::::::::::::::::::::::::::::::::::::::                 :: org.scala-sbt#sbt;0.13.9: not found                 :::::::::::::::::::::::::::::::::::::::::::::: :::: ERRORS         SERVER ERROR: Proxy Timeout ( The connection timed out. For more information about this event, see ISA Server Help.  ) url=http://repo2.maven.org/maven2/org/scala-sbt/sbt/0 .13.9/sbt-0.13.9.pom :: USE VERBOSE OR DEBUG MESSAGE LEVEL FOR MORE DETAILS unresolved dependency: org.scala-sbt#sbt;0.13.9: not found Error during sbt execution: Error retrieving required libraries   (see D:\work\scala\sbt\.sbt\boot\update.log for complete log) Error: Could not retrieve sbt 0.13.9

2.3 在環境變數PATH中新增D:\sbt\tool\bin

3.Idea中設定

3.1 在idea中確保正確安裝了scala外掛

3.2 檔案 -> 其他設定 -> 預設設定中如下設定

VM parameters:

複製程式碼
-XX:MaxPermSize=512M
-Dsbt.log.format=true
-Dsbt.global.base=D:/tool/sbt/.sbt
-Dsbt.ivy.home=D:/tool/sbt/.ivy2
-Dsbt.boot.directory=D:/tool/.sbt/boot/
-Dsbt.repository.config=D:/tool/sbt/conf/repo.properties
複製程式碼

到此配置結束。