【问题标题】:How do I get Intellij IDEA 12.0 to work with Play Framework 2.1.0 app and Scala 2.10.0?如何让 Intellij IDEA 12.0 与 Play Framework 2.1.0 应用程序和 Scala 2.10.0 一起使用?
【发布时间】:2013-02-17 09:14:20
【问题描述】:

所以我一直在尝试让 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      
  )
}

【问题讨论】:

  • 我就是这样工作的。有什么大不了的? Idea 无法编译 .scala.html 文件。您也可以尝试使用“~run”运行 Play,它会在文件写入后立即编译。不确定 Idea 是否会立即检测到这些新文件。
  • 是的,目前这还不算什么大事。我想插件很快就会更新,并且不需要这一步。感谢您的输入
  • 您使用的是什么版本的插件?他们现在在插件方面遇到了一些大问题。看看这个:stackoverflow.com/questions/17329977/…
  • 如果我的回答解决了您的问题,请标记为已解决,谢谢。

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


【解决方案1】:

我认为这就是它目前的工作方式。正如@pedrofurla 所建议的,您可以让~run 在 sbt/play 控制台上运行。可悲的是,IMO 没有其他方式 IntelliJ 可以自动编译您的 scala 视图。

【讨论】:

    【解决方案2】:

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

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

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

    希望这会有所帮助。

    【讨论】:

      【解决方案3】:

      只需将以下内容添加到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")
      

      【讨论】:

      猜你喜欢
      • 2013-04-14
      • 1970-01-01
      • 1970-01-01
      • 2013-10-02
      • 2015-08-16
      • 1970-01-01
      • 1970-01-01
      • 2015-12-28
      • 1970-01-01
      相关资源
      最近更新 更多