我安装了以下内容: 1.播放2.4 2.处理了一个scala项目 3.添加了eclipse插件
现在我想添加一个数据库连接。我想尝试使用ReactiveMongo,但维基页面上的说明适用于2.3或更早版本。
https://github.com/ReactiveMongo/Play-ReactiveMongo
对于2.4,似乎播放的文件结构已经改变。我需要知道为ReactiveMongo配置play 2.4的正确方法。
以下是他们为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
如何将配置应用于play 2.4的新文件结构?
这是我试图做的没有成功: 在项目/ plugins.sbt中,我添加了:
resolvers += "Sonatype Snapshots" at "https://oss.sonatype.org/content/repositories/snapshots/"
addSbtPlugin("org.reactivemongo" % "play2-reactivemongo" % "0.11.0-SNAPSHOT")
我收到一条解决错误消息:
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
因此,在得知我需要将依赖项添加到/build.sbt文件并在那里进行更改之后。
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
执行这些步骤后,我想验证是否正确安装。所以我试图将教程代码添加到我的项目中 https://github.com/ReactiveMongo/Play-ReactiveMongo
/app
/controllers/Application.scala
/controllers/UsingJsonReadersWriters.scala
/models/models.scala
/conf
/routes
然后我做一个活化剂清洁 然后我做了一个激活器运行
我在运行后看到错误:
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.
所以,似乎我的安装失败了。所以,这个问题仍然存在。
答案 0 :(得分:1)
将以下行添加到sub AskUser
dim Answer as string
dim i as integer
dim Number as integer
Answer = Inputbox("Your text here")
Number = CInt(Answer) 'Note this will throw an error if you enter something that's not a numbeer
for i = 1 to Number
'code
next i
End sub
:
build.sbt
例如:
"org.reactivemongo" %% "play2-reactivemongo" % "0.11.0.play24"
关于反应性mongo的例子,我从来没有让它们起作用。我想他们可能有点过时了。尝试(不是最好的例子,但很简单):
libraryDependencies ++= Seq(
jdbc,
cache,
ws,
specs2 % Test,
"org.reactivemongo" %% "play2-reactivemongo" % "0.11.0.play24",
"org.scalatest" % "scalatest_2.11" % "2.2.4" % "test"
)
答案 1 :(得分:1)
如果有人仍在寻找答案:在Play 2.4.x中,要添加到build.sbt
的依赖关系看起来像这样......
ReactiveMongo 0.11.7 :
libraryDependencies ++= Seq(
// ...
"org.reactivemongo" %% "play2-reactivemongo" % "0.11.7.play24"
)
ReactiveMongo 0.11.9 (2015年12月20日发布):
scalaVersion := "2.11.7"
libraryDependencies ++= Seq(
// ...
"org.reactivemongo" % "play2-reactivemongo_2.11" % "0.11.9"
// Or to let SBT add the Scala version suffix automatically:
"org.reactivemongo" %% "play2-reactivemongo" % "0.11.9"
)
请注意,命名似乎时有变化。对于以后的版本,您可以尝试以下步骤:
g:"org.reactivemongo" play
。play2-reactivemongo_2.11
如果你有Scala 2.11.x
。0.11.9
),即可转到this这样的网页。build.sbt
文件中。如果您有libraryDependencies ++= Seq(...)
部分,请仅复制+=
之后的部分。