I've been following this tutorial to get accustomed to the Play framework:
http://www.playframework.org/documentation/2.0.2/ScalaTodoList
When reaching the "Persist the tasks in a database" segment, it is unclear to me whether I have to do anything to start up the database or if this is done automatically for me. I am currently receiving this error:
[Exception: DB plugin is not registered.]
It depends on the type of database you use.
H2 database (the one used in Play! tutorial) can be used as an in-memory database or as a disk based database. Play will handle all for you if you go for this database. You don't have to run a specific service to have the persistent database.
But you will have to describe in your application.conf which driver to use and which url to access :
db.default.driver=org.h2.Driver
db.default.url="jdbc:h2:mem:play"
As you probably don't have the right driver in your classpath, you would have to include this driver lib. As explained in Play2 documentation, you can manage this in project/Build.scala. For h2 driver lib the dependency will be :
val appDependencies = Seq(
"com.h2database" % "h2" % "1.3.167"
)
After having changed your dependencies, you will need to reload the application build file and update the dependencies :
//in sbt
reload
update
How to link your play application with a database is explained here
If you want to use an other database (Mysql, Postgresql...) you will have to run the database service yourself and repeat the steps described here.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With