3
votes

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?

1
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
@CyrilleCorpet I've got sbt version 0.13.15. And I just use the sbt CLI. So to run my project I do sbt runGordon13
Also, I'm using play 2.5, and my sbt-plugin version is 2.5.14Gordon13
If issue happens in idea solely, refresh its dependencies: Open SBT toolwindow (on the right side of IDE) and press refresh button. stackoverflow.com/questions/20413605/…Clément Hurlin

1 Answers

10
votes

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.