我創建了一個階發揮項目這樣斯卡拉播放和多項目SBT構建
activator new foo play-event-sourcing-starter
已成功生成項目,我可以進去,輕鬆地編譯和運行應用程序。
但是我想要的是我應該有一個多項目sbt構建。我GOOGLE了,發現這https://www.playframework.com/documentation/2.5.x/SBTSubProjects
但這不是我想要的,因爲在這裏他們有發揮作爲根項目。而我想要的是,我有一個空的根項目與build.sbt文件,然後多個「同行」項目。其中之一就是玩。
因此,我改變步驟
mkdir -p LearnPlay/project
cd LearnPlay
activator new foo play-event-sourcing-starter
現在我走了進去foo和移動build.sbt
到LearnPlay目錄。我還將build.properties
和plugins.sbt
文件移動到LearnPlay/project文件夾中。
我編輯的build.sbt文件,以便根項目成爲
lazy val root = (project in file("foo")).enablePlugins(PlayScala)
但是現在SBT不能再編譯該項目,它不能找到任何播放框架依賴。
sbt.ResolveException: unresolved dependency: com.typesafe.play#play-server_2.10;2.5.9: not found
unresolved dependency: com.typesafe.play#play-netty-server_2.10;2.5.9: not found
unresolved dependency: com.typesafe.play#play-logback_2.10;2.5.9: not found
unresolved dependency: com.typesafe.play#play-test_2.10;2.5.9: not found
unresolved dependency: com.typesafe.play#play-omnidoc_2.10;2.5.9: not found
at sbt.IvyActions$.sbt$IvyActions$$resolve(IvyActions.scala:313)
這些是我的plugins.sbt文件的內容。解析器的定義是正確的,所以我不確定爲什麼在文件從子項目移動到根項目後sbt將無法找到依賴項。當文件位於foo項目的項目目錄中時,它能夠解決所有問題。
resolvers += "Typesafe repository" at "http://repo.typesafe.com/typesafe/releases/"
// The Play plugin
addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.5.9")
// web plugins
addSbtPlugin("com.typesafe.sbt" % "sbt-digest" % "1.1.0")
你是正確的,但添加
scalaVersion
參數和設置的東西它是一個有點令人驚訝,因爲scalaVersion是在sbt項目中指定,但不直接在根項目本身上指定。當它在根項目中時,它能夠選擇正確的scala版本......但不能在使用該目錄時使用。 –你能完整展示你的build.sbt嗎? – Mysterion