I have installed the following: 1.Play 2.4 2.Created a scala project 3.added the eclipse plugin
Now I wanted to add a database connection. I want to tryout ReactiveMongo, but the instructions on the wiki page are for 2.3 or older.
https://github.com/ReactiveMongo/Play-ReactiveMongo
For 2.4 it seems like the file structure of play has changed. I need to know the proper way to configure play 2.4 for ReactiveMongo.
Here are the instructions that they give for play versions newer than 2.4:
If you want to use the latest snapshot, add the following instead (only for play > 2.3):
resolvers += "Sonatype Snapshots" at "https://oss.sonatype.org/content/repositories/snapshots/"
libraryDependencies ++= Seq(
"org.reactivemongo" %% "play2-reactivemongo" % "0.11.0-SNAPSHOT"
)
Configure your application to use ReactiveMongo plugin
add to your conf/play.plugins
1100:play.modules.reactivemongo.ReactiveMongoPlugin
Configure your database access within application.conf
How would I apply there configuration to the new file structure of play 2.4?
This is what I attempted to do with no success: In the project/plugins.sbt I added:
resolvers += "Sonatype Snapshots" at "https://oss.sonatype.org/content/repositories/snapshots/"
addSbtPlugin("org.reactivemongo" % "play2-reactivemongo" % "0.11.0-SNAPSHOT")
I get a resolving error message:
at java.lang.Thread.run(Thread.java:745)
[error] (*:update) sbt.ResolveException: unresolved dependency: org.reactivemong
o#play2-reactivemongo;0.11.0-SNAPSHOT: not found
So, after learning that I needed to add the dependency to the /build.sbt file and made the changes there.
name := """oneid-scala"""
version := "1.0-SNAPSHOT"
lazy val root = (project in file(".")).enablePlugins(PlayScala)
scalaVersion := "2.11.6"
libraryDependencies ++= Seq(
jdbc,
cache,
ws,
specs2 % Test
)
resolvers += "scalaz-bintray" at "http://dl.bintray.com/scalaz/releases"
//This is for reactivemongodb
resolvers += "Sonatype Snapshots" at "https://oss.sonatype.org/content/repositories/snapshots/"
//This is for reactivemongodb
libraryDependencies ++= Seq(
"org.reactivemongo" %% "play2-reactivemongo" % "0.11.0-SNAPSHOT"
)
// Play provides two styles of routers, one expects its actions to be injected, the
// other, legacy style, accesses its actions statically.
routesGenerator := InjectedRoutesGenerator
EclipseKeys.createSrc := EclipseCreateSrc.All
After doing these steps I wanted to verify if I did the installation correctly. So I attempted to add the tutorial code to my project from https://github.com/ReactiveMongo/Play-ReactiveMongo
/app
/controllers/Application.scala
/controllers/UsingJsonReadersWriters.scala
/models/models.scala
/conf
/routes
Then I do an activator clean Then I do a activator run
I see an error after the run:
missing or invalid dependency detected while loading class file 'JSONGenericHandlers.class'.
Could not access type GenericHandlers in package reactivemongo.api.collections, because it (or its dependencies) are missing.
Check your build definition for missing or conflicting dependencies.
(Re-run with `-Ylog-classpath` to see the problematic classpath.)
A full rebuild may help if 'JSONGenericHandlers.class' was compiled against an incompatible version of reactivemongo.api.collections.
So, it seems that my install failed. So, this question is still open.