Compilation error when testing non blocking Redis client (Fyrie) on Play Framework 2.1

白昼怎懂夜的黑 提交于 2020-01-05 08:07:51

问题


when I try to compile the following code

import play.api._
import play.api.mvc._
import scala.collection.mutable.StringBuilder
import net.fyrie.redis.RedisClient
import net.fyrie.redis.RedisClientConfig
//import akka.dispatch._
//import akka.dispatch.Future

object Application extends Controller {

  //  val rd: RedisClient = new RedisClient("localhost", 6379, new RedisClientConfig(1, true, true, 50 to 100))(akka.actor.ActorSystem.create)
  val rd = RedisClient.apply("localhost", 6379, new RedisClientConfig(1, true, true, 50 to 100))(akka.actor.ActorSystem.create)

  def nonblocktest(application: String, platform: String) = Action {
    val future: akka.dispatch.Future[Option[akka.util.ByteString]] = rd.get(StringBuilder.newBuilder.append(application).append('-').append(platform).toString)
    future onSuccess {
      case x => Ok(x.get.toString)
    } onFailure {
      case t: Throwable => Results.NoContent
    }
    Results.NoContent
  }

}

I get the following error

sbt.PlayExceptions$CompilationException: Compilation error[package dispatch contains object and package with same name: japi
one of them needs to be removed from classpath]
        at sbt.PlayReloader$$anon$2$$anonfun$reload$2$$anonfun$apply$15$$anonfun$apply$16.apply(PlayReloader.scala:349) ~[na:na]
        at sbt.PlayReloader$$anon$2$$anonfun$reload$2$$anonfun$apply$15$$anonfun$apply$16.apply(PlayReloader.scala:349) ~[na:na]
        at scala.Option.map(Option.scala:133) ~[scala-library.jar:na]
        at sbt.PlayReloader$$anon$2$$anonfun$reload$2$$anonfun$apply$15.apply(PlayReloader.scala:349) ~[na:na]
        at sbt.PlayReloader$$anon$2$$anonfun$reload$2$$anonfun$apply$15.apply(PlayReloader.scala:346) ~[na:na]
        at scala.Option.map(Option.scala:133) ~[scala-library.jar:na]

I get the same if I uncomment any of the last two imports. I am trying to use fyrie for scala 2.10.0 in play framework 2.1.0. My goal is to test fyrie non blocking async calls performances against sedis (blocking). So what am I doing wrong? Knowing myself it could be something very (VERY) dumb.

Thanks for any help.


回答1:


You should probably try to use this fork of fyrie redis, as the main repo seems to be dead and is using old dev versions of scala and akka.



来源:https://stackoverflow.com/questions/16144747/compilation-error-when-testing-non-blocking-redis-client-fyrie-on-play-framewo

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!