使用空白 Scala Lift sbt 模板设置 MongoDB 所需的具体步骤是什么?
我是 Web 开发新手,但拥有丰富的 Scala 经验,并且正在尝试开始使用 Lift。第一步似乎是设置数据库连接,以便站点可以存储用户信息,但我不太清楚如何做到这一点。我发现的许多资源都要求我具备某些我似乎不具备的先验知识。根据我的阅读,MongoDB 似乎是最佳选择。鉴于我计划存储各种用户信息、文本和大量图片,这个结论正确吗?
配置 MongoDB 数据库连接并设置用户类来使用它需要哪些具体步骤?我从使用 Lift 2.3 和 Scala 2.8.1 的“lift_basic”模板开始。
到目前为止,我已经尝试修改 LiftProject 文件以包含 lift-mongodb 依赖项,根据 Lift Mongo wiki 条目为 Boot.scala 文件编写 mongoInit 函数,并尝试使用本邮件中提到的 MetaMegaProtoUser 类的 Mongo 版本列出线程。但这似乎不起作用,我收到“正在查找连接标识符 ConnectionIdentifier(lift) 但未能找到具有名称 lift 的 JNDI 数据源或具有正确名称的 lift 连接管理器”错误。这似乎来自该行,
Schemifier.schemify(true, Schemifier.infoF _, User)
但我不知道该行的含义/作用是什么,所以我很困惑。
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 coming from the line
Schemifier.schemify(true, Schemifier.infoF _, User)
But I have no idea what this line means / does so I'm stumped.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为通常情况下,您不需要 MongoDb 的 schemifier。 (我认为 MongoDB 无论如何都没有 JNDI 数据源,因此连接管理与所有 Java API 内容有点脱钩。因此,一切都与 SQL 数据库有点不同。)
此外,如果您只开始使用 lift ,使用默认的h2数据库更容易管理,因为大多数示例只是使用默认的;但您可能还想检查 https://github.com/regadas/lift-mongodb-sample< /a> 这为您提供了基本的 MongoDB 设置。 (不过不确定它是否有效。)
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.)