如何让Intellij IDEA 12.0与Play Framework 2.1.0应用程序和Scala 2.10.0一起工作?

12
我一直在尝试让 IDEA 12.0 与 Play 2.1.0 和 Scala 2.10.0 兼容。但是,由于无法按照我的意愿工作,我已经放弃了。以下是我的 build.properties、Build.scala 和 plugins.sbt 的副本。我遵循了 playframework 网站上的方法,在 play console 中执行 idea with-sources=yes。我还尝试添加 sbt-idea 插件版本 1.3.0-SNAPSHOT(如 plugins.sbt 中所示),但如果我想引用新创建的视图模板或新路由,则似乎没有任何方法可以正常工作。我唯一能在 IDEA 中工作的方式是打开控制台并运行 sbt compile,然后返回到 IDEA,它会刷新自身并识别新的视图模板或路由。

plugins.sbt

logLevel := Level.Warn

scalaVersion := "2.10.0"

// The Typesafe repository 
resolvers += "Typesafe repository" at "http://repo.typesafe.com/typesafe/releases/"
// Sonatype snapshots to get sbt-idea 1.3.0-SNAPSHOT
//resolvers += "Sonatype snapshots" at "http://oss.sonatype.org/content/repositories/snapshots/"

// Use the Play sbt plugin for Play projects
addSbtPlugin("play" % "sbt-plugin" % "2.1.0")
//addSbtPlugin("com.github.mpeltonen" % "sbt-idea" % "1.3.0-SNAPSHOT")

build.properties

sbt.version=0.12.2

Build.scala

import sbt._
import Keys._
import play.Project._

object ApplicationBuild extends Build {

  val appName         = "admin-application"
  val appVersion      = "1.0-SNAPSHOT"

  val appDependencies = Seq(
    // Add your project dependencies here,
    jdbc,
    anorm
  )

  val main = play.Project(appName, appVersion, appDependencies).settings(
    // Add your own project settings here      
  )
}

这就是我的工作方式,有什么大不了的?Idea无法编译 .scala.html 文件。您也可以尝试使用“〜run”运行Play,在文件被写入时即进行编译。不确定Idea能否立即检测到这些新文件。 - pedrofurla
没错,目前这不是一个很大的问题。我想插件很快就会更新,使得这一步骤变得不必要。感谢您的建议。 - Adrian Rodriguez
你使用的插件版本是什么?它们目前在插件方面存在一些严重的问题。看看这个链接:https://dev59.com/_HPYa4cB1Zd3GeqPnMnl - jakob
如果我的回答解决了您的问题,请标记为已解决,谢谢。 - teemoo
3个回答

14
如果您使用的是 IDEA 社区版,可以使用 SBT Console 插件(请参见 http://plugins.jetbrains.com/plugin?pluginId=5007)直接在编辑器中编译/运行 Play 项目。这是我每天工作的方式,非常好用(我使用 ~run 命令,然后就不需要再关心了)。
您还可以在 IDEA 中添加一个远程调试器,监听您本地服务器(如果以调试模式运行),并像往常一样使用它。
如果您使用的是 IDEA 旗舰版,则 JetBrains 推出了一个 Play Framework 插件,似乎也很好用(但我还没有测试过)。请查看这些教程:

希望这能有所帮助。


0
只需将以下内容添加到 project/plugins.sbt 中,然后重新运行 play idea
   // FIX SBT IDEA  PLAY 2.1  
   resolvers += "Typesafe repository" at "http://repo.typesafe.com/typesafe/releases/"  

  // Use the Play sbt plugin for Play projects  
   addSbtPlugin("play" % "sbt-plugin" % "2.1.0")

使用最新版本的Play框架,这个“技巧”不再需要。http://www.playframework.com/documentation/2.2.x/Migration22 - Lord of the Goo

0

我认为这是当前的工作方式。正如@pedrofurla所建议的那样,您可以在sbt/play控制台上保持~run运行。不幸的是,在我看来,IntelliJ没有其他自动编译Scala视图的方法。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接