简体   繁体   中英

SBT compilation for play framework 2.x disabled by default

I created a new Play Framework project using the activator, activator new my-project-name and then I selected the play-java template and the project is created with no errors.

Then I import the project into my IDE, IntelliJ, as a SBT project. When the project is imported a popup is shown saying: SBT compilation for play framework 2.x disabled by default .

On IntelliJ project's panel it doesn't show all (mostly the files with the code) files. Just a handful of them.

在此输入图像描述

The build.sbt file looks like full of compilation error (pretty much all the lines are red underlined).

Here's the build.sbt file

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

I can compile and run the code with activator ui with no errors. So, why isn't IntelliJ fully importing the project and it shows me SBT compilation for play framework 2.x disabled by default message?

I googled around and couldn't find any hint related to this so I'm kinda lost here.

EDIT: -------------------------------------

I closed the project on IntelliJ and deleted the project folder. Closed IntelliJ and using activator I created again the same project. Using activator ui I compiled the project. Then I fired up IntelliJ and was prompted to either open a project, create a new one or import a project.

Selected import a project and did the normal "import a project steps" and IntelliJ imported the project with no hassle. But if I try to import the project while with an open project on IntelliJ I get the same problem that lead me to make this question. Maybe this is a bug on IntelliJ?

EDIT 2 ------------------------------------------

The solution to these two problems (the " SBT compilation for play framework 2.x disabled by default " and the files not showing on IntelliJ) can be fixed with user3384225 and DarkShadow answers.

Preferences > Languages & Frameworks > Play2

Under 'Compiler' enable 'Use Play 2 compiler for this project'

在此输入图像描述

I Stumbled upon this problem myself when configuring play framework for IntelliJ IDEA IDE (version: 2017.3). I overcame this problem by following the steps below.

Navigate to:

File --> Settings --> Languages and Frameworks --> Play2 --> Compiler tab

and inside the compiler tab:

put a tick to the Use Play2 compiler for this project

在此输入图像描述

Hope this helped.

Similar answer to user3384225's answer was posted here:

They say:

  • Settings -> Langauges & Frameworks -> Play2 -> Compiler -> User Play 2 compiler for this project

I am also a newbie and was facing the same problem till yesterday. Probably you are trying to open the project through File->open.

Try the steps below:-

File->New->Project from existing source->select the build.sbt from the project you created using the activator->Import project from external model and select SBT from the options->OK.

It will take some time to import files and to create the settings required for intellij idea project. I am using intellij idea 14.1.5. It worked for me hope it will for you also.

对于当前项目,您可以使用File->Invalidate Caches/Restart..来解决此问题File->Invalidate Caches/Restart..

很可能你已经解决了你的问题,但只是为了帮助别人你只需要做 - >在首选项 - >语言和框架 - > Play2 - >编译器下选择“为这个项目使用Play 2编译器”选项

Stumbled upon the same problem today. Solved by wiping the ~/.IntelliJIdea14 directory. Unfortunately any other things I've tried didn't help.

Just use: File->New->Project from existing source->select the build.sbt from the project you created using the activator->ok. and it's done.

Close the project and then import the project as sbt project. Intellij will automatically dump and index the project dependancies.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM