I'm new to web development but have plenty of Scala experience and am trying to get started with Lift. One of the first steps seems to be setting up a database connection so a site can store user information but I can't quite figure out how to do this. Many of the sources I've found expect certain prior knowledge that I don't seem to have. From what I've read MongoDB seems to be the way to go. Given that I plan to store various user information, text, and lots of pictures is that conclusion correct?
What are the exact steps needed to configure a MongoDB database connection and setting up a user class to use it? I'm starting from a "lift_basic" template using Lift 2.3 and Scala 2.8.1.
So far I've tried modifying the LiftProject file to include the lift-mongodb dependencies, written a mongoInit function for the Boot.scala file based on the Lift Mongo wiki entry, and tried using the Mongo version of the MetaMegaProtoUser class mentioned in this mailing list thread. That doesn't seem to have worked though and I get a "Looking for Connection Identifier ConnectionIdentifier(lift) but failed to find either a JNDI data source with the name lift or a lift connection manager with the correct name" error. This seems to be com开发者_运维百科ing from the line
Schemifier.schemify(true, Schemifier.infoF _, User)
But I have no idea what this line means / does so I'm stumped.
I think usually, you do not need a schemifier for MongoDb. (I think there is no JNDI data source for MongoDB anyway, so the connection management is a bit decoupled from all that Java API stuff. Therefore everything is a bit different than with a SQL database.)
Also, if you have only started with lift, using the default h2 database is easier to manage because most examples just use the default; but you may also want to check https://github.com/regadas/lift-mongodb-sample which gives you a basic MongoDB setup. (Not sure if it works, though.)
精彩评论