如何让 Intellij IDEA 12.0 与 Play Framework 2.1.0 应用程序和 Scala 2.10.0 一起使用?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/15181971/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How do I get Intellij IDEA 12.0 to work with Play Framework 2.1.0 app and Scala 2.10.0?
提问by Adrian Rodriguez
So I've been trying to get IDEA 12.0 to work with Play 2.1.0 and Scala 2.10.0. I've just about given up because it's not working for me the way I want it to. Here is a copy of my build.properties, Build.scala, and plugins.sbt. I followed the approach on the playframework site to execute idea with-sources=yesin the play console. I've also tried adding sbt-ideaplugin version 1.3.0-SNAPSHOT as seen in plugins.sbt, but nothing seems to work if I want to reference a new view template I just created or a new route. The only way I can work in IDEA is if I have a console open and run sbt compile, go back to IDEA, and it will refresh itself and recognize the new view templates or routes.
所以我一直试图让 IDEA 12.0 与 Play 2.1.0 和 Scala 2.10.0 一起工作。我几乎要放弃了,因为它对我来说并不像我想要的那样工作。这是我的一个副本build.properties,Build.scala和plugins.sbt。我按照 playframework 站点上的方法在idea with-sources=yes播放控制台中执行。我还尝试添加sbt-idea插件版本 1.3.0-SNAPSHOT,如 plugins.sbt 中所示,但如果我想引用我刚刚创建的新视图模板或新路由,似乎没有任何效果。我可以在 IDEA 中工作的唯一方法是,如果我打开并运行一个控制台sbt compile,返回到 IDEA,它会自行刷新并识别新的视图模板或路由。
plugins.sbt
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
build.properties
sbt.version=0.12.2
Build.scala
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
)
}
回答by teemoo
If you use IDEA Communityedition, there is a SBT Console plugin (see http://plugins.jetbrains.com/plugin?pluginId=5007) that allows you to compile / run your Play project directly in the editor. That's the way I work every day and it is fine (I use the ~runcommand and then don't care anymore).
如果您使用 IDEA社区版,则有一个 SBT 控制台插件(请参阅http://plugins.jetbrains.com/plugin?pluginId=5007)允许您直接在编辑器中编译/运行您的 Play 项目。这就是我每天工作的方式,很好(我使用~run命令然后不再关心了)。
You may also add a remote debugger in IDEA that listens to you local server (it it is run with debug mode on) and use it as usual.
您还可以在 IDEA 中添加一个远程调试器来侦听您的本地服务器(它在调试模式下运行)并像往常一样使用它。
If you use IDEA Ultimateedition, JetBrains released a Play Framework plugin that seems to work fine (but I haven't tested it yet). Have a look at these tutorials:
如果您使用 IDEA Ultimate版,JetBrains 发布了一个 Play Framework 插件,它似乎工作正常(但我还没有测试过)。看看这些教程:
- http://confluence.jetbrains.com/display/IntelliJIDEA/Play+Framework+2.0or
- http://www.jamesward.com/2013/01/23/video-create-and-run-play-framework-apps-in-intellij
- http://confluence.jetbrains.com/display/IntelliJIDEA/Play+Framework+2.0或
- http://www.jamesward.com/2013/01/23/video-create-and-run-play-framework-apps-in-intellij
Hope this helps.
希望这可以帮助。
回答by Garbage
I think this is how it work currently. As suggested by @pedrofurla, you can keep ~runrunning on sbt/play console. Sadly, IMO there is no other way IntelliJ can compile your scala views automatically.
我认为这就是它目前的工作方式。正如@pedrofurla 所建议的,您可以继续~run在 sbt/play 控制台上运行。遗憾的是,IMO 没有其他方法可以让 IntelliJ 自动编译您的 Scala 视图。
回答by dimetron
Just add to project/plugins.sbtthe following and re-run play idea
只需添加到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")

![Scala 中带有方括号 (private[...]) 的私有范围](/res/img/loading.gif)