I'm trying to use Google Guice Injections in my Play 2.2.2 project. My build.sbt
file contains this:
libraryDependencies ++= Seq(
javaJdbc,
javaEbean,
cache,
"com.google.inject" % "guice" % "4.0-beta",
"ws.securesocial" %% "securesocial" % "2.1.4",
"postgresql" % "postgresql" % "9.1-901-1.jdbc4"
)
When running play dependencies
, I can see that the guice dependency is being resolved correctly. However, when trying to make the import com.google.inject.*
statement it seems that the library is not available:
I don't have this problem with any other imported dependencies, what am I doing wrong here?
Try this command on console in your project directory -
your project dir $:> play compile eclipse
and then refresh your project on eclipse.
Play doesn't have any plugin on eclipse but play provide the utility to import your project into eclipse. so whenever you add a new dependency you should compile and eclipsify your project otherwise eclipse will not understand the new dependency imports.
tl;dr Execute
eclipse
task and refresh the project in Eclipse.As a quick check of the import being really in the dependency, execute
play console
and type inimport com.google.inject.*
. Ifsbt console
can resolve the import, it's an issue with Eclipse that didn't seem to refresh the project.Don't forget to
reload
an active session ofplay
after every change to the build.