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

时间:2013-03-03 03:00:03

标签: scala intellij-idea sbt playframework-2.1 sbt-idea

所以我一直在努力让IDEA 12.0与Play 2.1.0和Scala 2.10.0一起使用。我只是放弃了,因为它不像我想要的那样对我有用。以下是我的build.propertiesBuild.scalaplugins.sbt的副本。我按照playframework网站上的方法在Play控制台中执行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      
  )
}

3 个答案:

答案 0 :(得分:14)

如果您使用IDEA 社区版本,则会有一个SBT控制台插件(请参阅http://plugins.jetbrains.com/plugin?pluginId=5007),该插件允许您直接在编辑器中编译/运行Play项目。这就是我每天工作的方式,它很好(我使用~run命令,然后不再关心)。

您还可以在IDEA中添加一个远程调试器来侦听本地服务器(它在启用调试模式的情况下运行)并像往常一样使用它。

如果您使用IDEA Ultimate 版本,JetBrains发布了一个Play Framework插件似乎工作正常(但我还没有测试过)。看看这些教程:

希望这有帮助。

答案 1 :(得分:0)

我认为这是目前的工作方式。根据@pedrofurla的建议,您可以在sbt / play控制台上运行~run。遗憾的是,IMO没有其他方式IntelliJ可以自动编译你的scala视图。

答案 2 :(得分:0)

只需添加以下project/plugins.sbt并重新运行游戏创意

   // 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")