Reputation: 3602
I am trying to run Spray example on IntelliJ 14.
All looks OK and the server starts and shows a response.
But, I am having 2 major issues (probably 2 issues are connected):
1) For some reason when I add to my build.sbt file: "io.spray" %% "spray-json" % "1.2.6" it doesn't do anything (I cannot import spray.json).
2) IntelliJ shows an error on the line: Revolver.settings. I believe that this is the reason that when I change the code it doesn't change on browser refresh. The error that intelliJ shows is: "Expression type (Def.Settings Definition) must conform to Settings[_] in SBT file".
Does anyone have an idea of how to solve this issue?
My build.sbt after changing: Revolver.settings
to: Revolver.settings: Seq[sbt.Def.Setting[_]]
:
organization := "com.example"
version := "0.1"
scalaVersion := "2.10.4"
scalacOptions := Seq("-unchecked", "-deprecation", "-encoding", "utf8")
libraryDependencies ++= {
val akkaV = "2.3.6"
val sprayV = "1.3.2"
Seq(
"io.spray" %% "spray-json" % "1.2.6",
"io.spray" %% "spray-can" % sprayV,
"io.spray" %% "spray-routing" % sprayV,
"io.spray" %% "spray-testkit" % sprayV % "test",
"com.typesafe.akka" %% "akka-actor" % akkaV,
"com.typesafe.akka" %% "akka-testkit" % akkaV % "test",
"org.specs2" %% "specs2-core" % "2.3.7" % "test"
)
}
Revolver.settings: Seq[sbt.Def.Setting[_]]
Upvotes: 2
Views: 2868
Reputation: 2785
I've run into both of these issues in my time with IntelliJ 14. Here's some pointers:
Seq[sbt.Def.Setting[_]]
to Seq[sbt.Setting[_]]
everywhere (they are type aliases)Step 4 requires some explaining.
The Scala plugin provides compatibility with Play, Twirl, SBT and Scala, all in one bundle. One of the things it does is provide an SBT tool (it probably shows up on the right side of your IDEA window). When it is opened it looks like this:
You can either click the refresh icon (circular arrows) at the top left or right-click on your task names (scrupal
in the image) and choose "Refresh external project". These actions both do the same thing which is to run SBT, update the project, and regenerate the IntelliJ project files from the SBT settings and definitions.
You can make this happen a few others ways. You already discovered one way: restart IntelliJ IDEA. The other way is to set the Scala plugin's SBT support to "Auto Import". With this feature turned on, it will re-import the SBT settings and update your IDEA project whenever the SBT source files change. I generally keep this turned off because it is annoying to have it try to re-import (a lengthy process) after every few keystrokes when I'm modifying the files. So, I use the manual approach and tell IntelliJ when I want it to refresh.
To turn on auto-import go to the IntelliJ Preferences, select "Build, Execution, Deployment", select "Build Tools", select "SBT", and then in the right panel select your project and check the "Use auto-import" field. - Restart IntelliJ IDEA. You already discovered that this works. - Set the Scala plugin to "Auto import".
Upvotes: 2