16

I'm trying to run one of the type safe activator projects in IntelliJ 13.1 with the latest Play 2 and Scala plugins.

I can run the project through the typesafe activator no problems but when I try to open the activator project via the build.sbt file in IntelliJ it all seems to work until I try to run the thing via the Play 2 App run configuration. I get the following error;

"C:\Program Files\Java\jdk1.8.0\bin\java" -Dfile.encoding=UTF8 -Djline.terminal=none -Dsbt.log.noformat=true -Dsbt.global.base=C:\Users\nw\AppData\Local\Temp\sbt-global-plugin5970836074908902993stub -Xms512M -Xmx1024M -Xss1M -XX:+CMSClassUnloadingEnabled -XX:MaxPermSize=256M -classpath C:\Users\nw\.IntelliJIdea13\config\plugins\Scala\launcher\sbt-launch.jar xsbt.boot.Boot run
    Getting org.fusesource.jansi jansi 1.11 ...
    :: retrieving :: org.scala-sbt#boot-jansi
        confs: [default]
        1 artifacts copied, 0 already retrieved (111kB/37ms)
    Getting org.scala-sbt sbt 0.13.0 ...
    :: retrieving :: org.scala-sbt#boot-app
        confs: [default]
        43 artifacts copied, 0 already retrieved (12440kB/109ms)
    Getting Scala 2.10.2 (for sbt)...
    :: retrieving :: org.scala-sbt#boot-scala
        confs: [default]
        5 artifacts copied, 0 already retrieved (24390kB/62ms)
    [info] Set current project to modules (in build file:/J:/DEV/TYPESAFE/reactive-maps/.idea/modules/)
    java.lang.RuntimeException: No main class detected.
        at scala.sys.package$.error(package.scala:27)
    [trace] Stack trace suppressed: run 'last compile:run' for the full output.
    [error] (compile:run) No main class detected.
    [error] Total time: 0 s, completed 02/04/2014 10:31:12 PM
    Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=256M; support was removed in 8.0

    Process finished with exit code 1

My build.sbt looks like this;

name := """reactive-maps"""

version := "1.0-SNAPSHOT"

libraryDependencies ++= Seq(
  "com.typesafe.akka" %% "akka-actor" % "2.2.1",
  "com.typesafe.akka" %% "akka-contrib" % "2.2.1",
  "com.typesafe.play.extras" %% "play-geojson" % "1.0.0",
  "org.webjars" %% "webjars-play" % "2.2.1",
  "org.webjars" % "bootstrap" % "3.0.0",
  "org.webjars" % "knockout" % "2.3.0",
  "org.webjars" % "requirejs" % "2.1.8",
  "org.webjars" % "leaflet" % "0.7.2"
)

play.Project.playScalaSettings

Just running sbt run from the command line in the project folder works fine. So there is some issue with the way the SBT project has been imported.

4

2 回答 2

17

您也可以使用 play 来修复它

cd /path/to/project
play
[project] idea with-sources=yes

现在您可以右键单击应用程序并运行 Play2 应用程序。

于 2014-07-02T23:31:42.823 回答
10

刚刚遇到了同样的问题 - 我的项目是这样设置的:

root/
  .idea/
  MainApp/ <-- this one is a Play 2.2.2 project
    .idea/
    apps/ <-- contains other Play2 projects

我试图运行该MainApp项目并遇到了同样的问题。

如果您在运行错误中发现:[info] Set current project to modules (in build file:/J:/DEV/TYPESAFE/reactive-maps/.idea/modules/)

声明它正在将项目设置为modules. 你希望它是reactive-maps

我的也是这样 - 我的快速解决方案:

-- 找到文件.idea/modules/reactive-maps.iml,移动到根reactive-maps/目录。

-- 打开文件,Ctrl-F Ctrl-R(查找和替换)

-- 查找:$MODULE_DIR$/../..替换为:$MODULE_DIR$/

此时再次运行 Play2 应用程序。

理想的解决方案是正确导入它(我确信有办法做到这一点),但这让我的应用程序快速通过 IntelliJ 运行(尽管它可能会在重新启动/SBT 刷新时中断)。

于 2014-04-21T22:33:27.133 回答