0

我有与Alpakka MongoDB 类似的问题 - 在 MongoSource 中指定类型

所以我MongoSource在解决方案中实现了我自己的并使用了它:

object MyMongoSource {
  def apply[T](query: Observable[T]): Source[T, NotUsed] =
    Source.fromPublisher(ObservableToPublisher(query))
}

val source: Source[Book, NotUsed] = MyMongoSource[Book](mongoDb.books.find()) 

但是ObservableToPublisherprivate class我收到以下错误:

object ObservableToPublisher in package mongodb cannot be accessed in package akka.stream.alpakka.mongodb

如何解决这个问题?

4

1 回答 1

0

定义MyMongoSourceakka.stream.alpakka.mongodb.scaladsl包中:

package akka.stream.alpakka.mongodb.scaladsl

import akka.NotUsed
import akka.stream.alpakka.mongodb.ObservableToPublisher
import akka.stream.scaladsl.Source
import org.mongodb.scala.Observable

object MyMongoSource {
  def apply[T](query: Observable[T]): Source[T, NotUsed] =
    Source.fromPublisher(ObservableToPublisher(query))
}
于 2018-03-12T15:33:57.417 回答