如何在Intellij

时间:2015-05-11 08:36:38

标签: scala intellij-idea sbt playframework-2.3

我有一个包含一些子项目的游戏项目。 我可以在类型安全激活器的控制台中运行播放应用程序1或2 - 有选择地如下。

$ activator "project collector" run
$ activator "project scheduler" run

但是,我无法在IntelliJ中找到任何参考和手册。 我该怎么办?

项目结构是这样的。

root
  - collector (play application 1)
    - app
    - conf
    - build.sbt
  - scheduler (play application 2)
    - app
    - conf
    - build.sbt
  - core
    - src
    - build.sbt
  - util
    - src
    - build.sbt
  - build.sbt

root的build.sbt文件如下所示。

import sbt.Keys._
lazy val commonSettings = Seq(
  organization := "com.xxxx",
  version := "1.0.0-SNAPSHOT",
  scalaVersion := "2.11.6",
  javacOptions in Compile ++= Seq("-source", "1.7", "-target", "1.7")
)

lazy val root = (project in file(".")).
  aggregate(core, collector, scheduler, util).
  enablePlugins(PlayScala).
  settings(
    name := "collector",
    version := "1.0",
    scalaVersion := "2.11.6"
  )


lazy val core = project.in(file("core")).
  settings(commonSettings: _*)

lazy val collector = project.in(file("collector")).
  dependsOn(core, util).
  settings(commonSettings: _*).
  enablePlugins(PlayScala, SbtWeb)

lazy val scheduler = project.in(file("scheduler")).
  dependsOn(core, util).
  settings(commonSettings: _*).
  enablePlugins(PlayScala, SbtWeb)

lazy val util = project.in(file("util")).
  settings(commonSettings: _*).
  dependsOn(core)

libraryDependencies ++= Seq(
  "io.spray" % "spray-io_2.11" % "1.3.2",
  "io.spray" % "spray-can_2.11" % "1.3.2",
  "io.spray" % "spray-client_2.11" % "1.3.2",
  "io.spray" % "spray-http_2.11" % "1.3.2",
  "io.spray" % "spray-httpx_2.11" % "1.3.2",
  "io.spray" % "spray-util_2.11" % "1.3.2",
  "com.typesafe.akka" % "akka-actor_2.11" % "2.3.7",
  "com.typesafe.akka" % "akka-contrib_2.11" % "2.3.7",
  "com.typesafe.slick" %% "slick" % "2.1.0"
)     


Keys.fork in Test := false

addCommandAlias("cc", ";clean;compile")

2 个答案:

答案 0 :(得分:0)

Play子模块不应单独运行,它们依赖于main项目。

  
      
  • 子项目没有自己的构建文件,但共享父项目的构建文件。

  •   
  • 特别是,必须只有一个application.conf文件和一个路径文件。

  •   

更多详情here

答案 1 :(得分:0)

关于intellij    点击菜单

  • 运行>编辑配置> “+”> SBT任务

    • 在SBT任务详细信息窗格
    • 在“任务”文本框中输入
    • “项目收藏家”运行
    • 在“名称”文本框中键入名称示例“run collector”
    • 点击“确定”
  • 点击“运行”> “跑者”

对您的其他项目重复上述步骤 参考

  • IntelliJ CE 2017.1
  • SBT 0.13.13