4

私のディレクトリ構造:

-build.sbt
-src
--main
---scala
----MongoConnect.scala
-lib

私のbuild.sbt

name := "mongodb-experiments"

version := "0.1"

libraryDependencies ++= Seq(
  "com.mongodb.casbah" %% "casbah" % "3.0.0-SNAPSHOT"
)

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

私の MongoConnect.scala プログラム:

import com.mongodb.casbah.Imports._
object MongoConnect{
  def main(args: Array[String]){
    println("Hello Mongo")
  }
}

なぜsbt compile_

オブジェクト casbah はパッケージ com.mongodb のメンバーではありません

?

sbt compile
[info] Set current project to mongodb-experiments (in build file:/Users/hrishikeshparanjape/git-public/mongodb-experiments/)
[info] Updating {file:/Users/hrishikeshparanjape/git-public/mongodb-experiments/}default-fc358e...
[info] Resolving org.scala-lang#scala-library;2.9.1 ...
[info] Resolving com.mongodb.casbah#casbah_2.9.1;3.0.0-SNAPSHOT ...
[info] Resolving com.mongodb.casbah#casbah-util_2.9.1;3.0.0-SNAPSHOT ...
[info] Resolving org.slf4j#slf4j-api;1.6.0 ...
[info] Resolving org.mongodb#mongo-java-driver;2.7.2 ...
[info] Resolving org.scalaj#scalaj-collection_2.9.1;1.2 ...
[info] Resolving org.scala-tools.time#time_2.8.0;0.2 ...
[info] Resolving joda-time#joda-time;1.6 ...
[info] Resolving com.mongodb.casbah#casbah-commons_2.9.1;3.0.0-SNAPSHOT ...
[info] Resolving com.mongodb.casbah#casbah-core_2.9.1;3.0.0-SNAPSHOT ...
[info] Resolving com.mongodb.casbah#casbah-query_2.9.1;3.0.0-SNAPSHOT ...
[info] Resolving com.mongodb.casbah#casbah-gridfs_2.9.1;3.0.0-SNAPSHOT ...
[info] Done updating.
[info] Compiling 1 Scala source to /Users/hrishikeshparanjape/git-public/mongodb-experiments/target/scala-2.9.1/classes...
[error] /Users/hrishikeshparanjape/git-public/mongodb-experiments/src/main/scala/MongoConnect.scala:1: object casbah is not a member of package com.mongodb
[error] import com.mongodb.casbah.Imports._
[error]                    ^
[error] one error found
[error] {file:/Users/hrishikeshparanjape/git-public/mongodb-experiments/}default-fc358e/compile:compile: Compilation failed
[error] Total time: 7 s, completed Jul 26, 2012 11:53:35 PM
4

2 に答える 2

4

古いバージョンの casbah でスナップショット リポジトリを使用するのはなぜですか?

libraryDependencies ++= Seq(
  "org.mongodb" %% "casbah" % "2.4.1"
)

resolvers += "typesafe" at "http://repo.typesafe.com/typesafe/releases/"

%% サインインの依存関係は、sbt scala バージョンで構成されたものを選択します

3.x バージョンにはマイルストーンがあります

libraryDependencies ++= Seq(
      "org.mongodb" %% "casbah" % "3.0.0-M2"
    )

そして、私が覚えているように、3.x のインポートは次のように変更する必要があります。

import com.mongodb.casbah._
于 2012-07-27T10:25:18.490 に答える
2

build.sbtファイルを次のように変更します。

name := "mongodb-experiments"

version := "0.1"

libraryDependencies ++= Seq(
  "com.mongodb.casbah" % "casbah_2.9.0" % "2.2.0-SNAPSHOT"
)

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

何らかの理由で、3.0.0は機能しません。

于 2012-07-27T07:26:55.850 に答える