Casbah Scala运行时错误 [英] Casbah Scala Runtime Error

查看:149
本文介绍了Casbah Scala运行时错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个基于Play框架的webapp,其build.sbt文件中定义了以下内容:

I have a Play framework based webapp which has the following defined in its build.sbt file:

....
version := "1.0-SNAPSHOT"

resolvers += "Sonatype Snapshots" at "http://oss.sonatype.org/content/repositories/snapshots/"

resolvers += "Sonatype Releases"  at "https://oss.sonatype.org/content/groups/scala-tools"

resolvers += "Novus Releases" at "http://repo.novus.com/releases/"

libraryDependencies ++= Seq(
  jdbc,
  anorm,
  cache,
  "com.mongodb.casbah" % "casbah_2.9.0" % "2.2.0-SNAPSHOT",
  "com.novus" %% "salat-core" % "1.9.2",
  "org.scalatest" % "scalatest_2.10" % "2.0" % "test",
  "com.typesafe" %  "config" % "1.0.2"
)
....

Scala版本为2.10.3,当我尝试运行单元测试时,遇到以下错误:

The Scala version is 2.10.3 and when I try to run a unit test, I run into the following error:

A needed class was not found. This could be due to an error in your runpath. Missing class: scala/reflect/ClassManifest
java.lang.NoClassDefFoundError: scala/reflect/ClassManifest
    at com.mongodb.casbah.Imports$.<init>(Implicits.scala:113)
    at com.mongodb.casbah.Imports$.<clinit>(Implicits.scala)
    at com.mongodb.casbah.MongoConnection.apply(MongoConnection.scala:177)
        ........
        ........

我完全一无所知为什么会这样呢?我缺少哪个附加库?

I'm completely clueless as to why this is happening? Which additional library is that I'm missing?

推荐答案

您不能混合主要 Scala版本(请参见,casbah工件是针对scala 2.9。*编译的,而scala_test是针对2.10。*的,您是说您在intellij中使用2.10。)

You can't mix major scala versions (see, casbah artifact is compiled against scala 2.9.*, whereas scala_test is for 2.10.*, and you're saying you use 2.10 in intellij).

错误说,编译器无法找到自2.9。*次以来从scala库切出的类,解决方案是选择适当的scala版本(任何2.10。*都适合)。

The error says, that compiler can't find class that was cut out from scala library since 2.9.* times and solution is to pick proper scala version (any 2.10.* will fit).

这篇关于Casbah Scala运行时错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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