In my Play 2.0 Framework Java project, the following line yields errors both in Eclipse and during the sbt compile step:
import javax.inject.*;
I already added the javax.inject
dependency to my build.sbt file:
libraryDependencies ++= Seq(
javaCore,
javaJdbc,
javaEbean,
javaWs,
javaFooBar,
cache,
"javax.inject" % "javax.inject" % "1",
"org.atmosphere" % "atmosphere-play" % "2.1.1"
)
and executed clean
, update
& eclipse with-source=true
like mad:
[myproject] $ eclipse with-source=true
[info] About to create Eclipse project files for your project(s).
[info] Compiling 3 Scala sources and 12 Java sources to ./myproject/target/scala-2.11/classes...
[error] ./myproject/app/com/elements/legacy/LegacyController.java:3: object inject is not a member of package javax
[error] import javax.inject.*;
[error] ^
[error] one error found
[error] (compile:compile) Compilation failed
[info] Resolving jline#jline;2.11 ...
[error] Could not create Eclipse project files:
[error] Error evaluating task 'dependencyClasspath': error
I have the feeling that sbt does not throw errors in case a dependency could not be resolved (e.g. javaFooBar above). How can this be activated?
How can I properly build a Play 2.0 Java project using javax.inject?
Thanks a lot!
Edit:
Extending the repository list in project/plugins.sbt in the following way did the trick:
// The repositories
resolvers ++= Seq(
Resolver.sonatypeRepo("snapshots"),
Resolver.sonatypeRepo("releases"),
Resolver.typesafeRepo("snapshots"),
Resolver.typesafeRepo("releases")
)
The dependencies
command as described by Donovan is very helpful to check whether a dependency could be resolved or not!