2014-04-02 28 views
16

我試圖在IntelliJ 13.1中使用最新的Play 2和Scala插件運行其中一個類型安全激活器項目。使用IntelliJ 13&SBT 0.13播放2.2.2無法運行 - 未檢測到主類

我可以通過類型安全的激活運行該項目沒有問題,但是當我試圖通過build.sbt文件中的IntelliJ這一切似乎工作,直到我試圖運行通過播放2應用程序運行配置的東西打開激活項目。我得到以下錯誤;

"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 

build.sbt看起來是這樣的;

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 

剛剛從項目文件夾中的命令行中運行sbt run工作正常。所以SBT項目導入的方式存在一些問題。

+0

可能想看看接受的答案的第3步http://stackoverflow.com/questions/16135716/how-to-use-intellij-with-play-framework-and-scala – Exupery

+0

此外,拿看看[這](http://stackoverflow.com/questions/22702175/creating-sbt-project-in-intellij-ultimate-13-1-1-with-scala-plugin-gives-no-new)。 –

回答

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-FCtrl-R(查找和替換)

- 查找:$MODULE_DIR$/../..替換爲:$MODULE_DIR$/

運行Play2再次申請工作在這一點上。

理想的解決方案是正確導入它(我確信有一種方法可以做到這一點),但是這使得我的應用程序很快通過IntelliJ運行(儘管它很可能在重新啓動/ SBT刷新時斷開)。

+0

這也適用於我。好的發現和感謝分享。 – eSniff

+0

從我注意到,當我從現有模塊/源導入項目(例如,將項目導入爲現有SBT模塊)時,會發生這種情況。從頭開始創建一個新項目總是工作 – Snnappie

+0

:)是的,這就是我所做的。 – eSniff

17

您還可以使用遊戲來修復它

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

現在你可以右鍵單擊應用程序並運行Play2應用。

+0

這工作對我來說,看起來像一個更清潔的解決方案。謝謝。 – mindreader

+4

這應該是被接受的答案。謝謝你的提示 –

+2

這對我有用,但不是'play'我用'sbt'(因爲播放命令適用於較老的播放版本) – JoseM

相關問題