I'm using spray with casbah and salat. I get this error when I import the casbah imports,

import com.mongodb.casbah.Imports._

object mongodb is not a member of package com

However, sbt compiles successfully w/o any warning. My build.sbt looks

scalaVersion  := "2.10.3"

scalacOptions := Seq("-unchecked", "-deprecation", "-encoding", "utf8")

resolvers ++= Seq(
  "spray repo" at "http://repo.spray.io/",
   "Sonatype releases" at "https://oss.sonatype.org/content/repositories/releases"
)

libraryDependencies ++= {
  val akkaV = "2.2.3"
  val sprayV = "1.2.0"
  Seq(
    "io.spray"            %   "spray-can"     % sprayV,
    "io.spray"            %   "spray-routing" % sprayV,
    "io.spray"            %   "spray-testkit" % sprayV  % "test",
    "com.typesafe.akka"   %%  "akka-actor"    % akkaV,
    "com.typesafe.akka"   %%  "akka-testkit"  % akkaV   % "test",
    "org.specs2"          %%  "specs2-core"   % "2.3.7" % "test",
    "org.mongodb"         %%  "casbah"        % "2.7.0-RC0",
    "com.novus"           %%  "salat"         % "1.9.5"
  )
}

Any idea on how to convince Eclipse to find the package?

有帮助吗?

解决方案 3

I ended up editing the original template spray project by adding the casbah and salat dependencies to the build.sbt, running sbt eclipse, and manually copying the new .classpath file to my imported eclipse project.

其他提示

Use sbteclipse plugin to configure eclipse project: https://github.com/typesafehub/sbteclipse

Salat uses Casbah 2.6.4 and has it listed as a dependency[1] so there may be an issue trying to have two different versions. Try changing it to 2.6.4 or removing it and allowing salat to implicitly declare it.

[1] https://github.com/novus/salat/blob/master/project/SalatBuild.scala#L150

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top