我使用activator创建了一个新的Play Framework项目:activator new my-project-name
,然后选择了play-java
模板,项目没有出现错误。
接下来,我将项目作为SBT项目导入到我的IDE IntelliJ中。当导入项目时,弹出窗口显示:默认情况下禁用Play Framework 2.x的SBT编译
。
在IntelliJ项目面板上,它并没有显示所有(大部分都是代码文件)的文件,只有其中一小部分。
build.sbt文件看起来充满了编译错误(几乎所有行都是红色下划线)。
这里是build.sbt文件:
name := """my-project-name"""
version := "1.0-SNAPSHOT"
lazy val root = (project in file(".")).enablePlugins(PlayJava)
scalaVersion := "2.11.6"
libraryDependencies ++= Seq(
javaJdbc,
cache,
javaWs
)
// Play provides two styles of routers, one expects its actions to be injected, the
// other, legacy style, accesses its actions statically.
routesGenerator := InjectedRoutesGenerator
fork in run := true
我可以使用activator ui
编译和运行代码,没有出现错误。那么,为什么IntelliJ没有完全导入项目,并显示"SBT compilation for play framework 2.x disabled by default
"的消息?
我在谷歌上搜索了一下,并没有找到相关的提示,所以我有点迷茫。
编辑:-------------------------------------
我关闭了IntelliJ上的项目并删除了该项目文件夹。关闭IntelliJ并使用activator
创建了同样的项目。我使用activator ui
编译了项目。然后启动了IntelliJ,提示我打开一个项目、创建新项目或导入项目。
选择导入一个项目并完成常规的“导入项目步骤”,IntelliJ无忧地导入了项目。 但是如果我尝试在IntelliJ上的一个打开项目中导入该项目,则会遇到与此问题相关的相同问题。也许这是IntelliJ上的一个bug?
编辑2:------------------------------------------
user3384225
和DarkShadow
的回答解决了这两个问题("SBT compilation for play framework 2.x disabled by default"和IntelliJ上未显示的文件)。