玩! 2框架 - 添加Java Mongo驱动程序 [英] Play! 2 Framework - Add Java Mongo driver

查看:122
本文介绍了玩! 2框架 - 添加Java Mongo驱动程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用Play的java mongo驱动程序。

I am trying to use the java mongo driver with Play!.

所以我读过:

http://www.playframework.org/documentation/2.0.2/SBTDependencies

http:/ /www.mongodb.org/display/DOCS/Java+Tutorial

我在eclipse中添加了buildpath。但是游戏无法找到依赖。

I added the buildpath in eclipse. But play can't find the dependency.

所以playframework主页上有一个例子,但我仍然无法弄明白。

So there is an example on the playframework homepage but I still can't figure it out.

val appDependencies = Seq(

      "org.scala-tools" %% "scala-stm" % "0.3",
      "org.apache.derby" % "derby" % "10.4.1.3" % "test"

    ) 

为什么两个百分号?我如何获得正确的名字?我只知道版本应该是2.8.0。
因此,如果我想添加Java驱动程序,我该怎么办?

Why are der two% signs? How do I get the correct names? I only know that the version should be 2.8.0. So if I want to add the Java driver, what do I have to do?

如果我使用官方的java驱动程序,我不必使用Morphia吗?

And if i use the official java driver, I don't have to use Morphia right?

< a href =https://stackoverflow.com/questions/10911698/installing-play-framework-mongodb-morphia-module>安装播放框架mongodb morphia模块

编辑:

import sbt._
import Keys._
import PlayProject._

object ApplicationBuild extends Build {

    val appName         = "website"
    val appVersion      = "1.0-SNAPSHOT"

    val appDependencies = Seq(
        "org.mongodb" % "mongo-java-driver" % "2.8.0"
        //"com.mongodb" % "Mongo" %"2.8.0"

    )

    val main = PlayProject(appName, appVersion, appDependencies, mainLang = JAVA).settings(
      // Add your own project settings here      
    )

}


推荐答案

添加MongoDB博士ivers到你的Play项目,编辑项目/ Build.scala 文件以添加MongoDB依赖项:

To add the MongoDB drivers to your Play project, edit your project/Build.scala file to add the MongoDB dependency:

val appDependencies = Seq(

   // ... here are your previous dependencies (derby etc...)
   "org.mongodb" % "mongo-java-driver" % "2.8.0"

) 

在你之后添加此项,您需要重新启动Play服务器才能使更改生效。

After you add this, you need to restart your Play server for the changes to take affect.

这篇关于玩! 2框架 - 添加Java Mongo驱动程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆