3

I'm trying to use the WS library in Play, but the import shown in all the tutorials I found doesn't work.

Has it changed somehow and the tutorials were not updated or is there something wrong with my setup?

I'm using: Scala 2.11 Play 2.5

This is in my build.sbt:

libraryDependencies ++= Seq(
   ws
)

This is the import in the code:

import play.api.libs.ws._

And this is the error:

object ws is not a member of package play.api.libs

Note: I saw the WS library was made optional in version 2.4 according to: https://www.playframework.com/documentation/2.4.x/Migration23#Play-WS

I tried using this import: import play.api.Play.current but I still get errors

Any ideas?

Gordon13
  • 464
  • 5
  • 21
  • There seems to be a problem between your sbt file and your compiler. Could you give your sbt version, sbt play-plugin precise version, and how you're compiling your project (CL sbt, intelliJ, ...)? – Cyrille Corpet Jun 07 '17 at 15:40
  • @CyrilleCorpet I've got sbt version 0.13.15. And I just use the sbt CLI. So to run my project I do `sbt run` – Gordon13 Jun 07 '17 at 15:52
  • Also, I'm using play 2.5, and my sbt-plugin version is 2.5.14 – Gordon13 Jun 07 '17 at 16:03
  • If issue happens in idea solely, refresh its dependencies: Open SBT toolwindow (on the right side of IDE) and press refresh button. https://stackoverflow.com/questions/20413605/how-to-force-intellij-idea-to-reload-dependencies-from-build-sbt-after-they-chan – Clément Hurlin May 28 '18 at 16:20

1 Answers1

10

Ok after spending a long time debugging, adding removing different version of the WS dependencie, the only thing I hadn't tried was restarting the sbt server.

So the solution is, when you add a new dependency or plugin etc, you must restart your server.

Gordon13
  • 464
  • 5
  • 21
  • 1
    Whenever you change your `build.sbt` file, you need to completely restart you app (CTRL+C, sbt run) because changes to `build.sbt` are not hot-reloaded like making a change to a controller. – Tyler Jun 07 '17 at 16:26