Scala java.lang.NoSuchMethodError:slick.driver.JdbcProfile$API.streamableQueryActionExtensionMethods

Scala java.lang.NoSuchMethodError:slick.driver.JdbcProfile$API.streamableQueryActionExtensionMethods,scala,playframework,slick,Scala,Playframework,Slick,我试着做一个正常的工作 使用正在运行的db.run(tableQ.result)进行“选择” 受保护的val表格Q:TableQuery[T] 通过示例,看起来我做得不错,但我得到了错误:play.api.http.HttpErrorHandlerExceptions$$anon$1:ExecutionException[[RuntimeException:java.lang.NoSuchMethodError:slick.driver.JdbcProfile]$ 我找到的原因是这行代码 Cau

我试着做一个正常的工作

使用正在运行的db.run(tableQ.result)进行“选择”

受保护的val表格Q:TableQuery[T] 通过示例,看起来我做得不错,但我得到了错误:play.api.http.HttpErrorHandlerExceptions$$anon$1:ExecutionException[[RuntimeException:java.lang.NoSuchMethodError:slick.driver.JdbcProfile]$

我找到的原因是这行代码

Caused by: java.lang.NoSuchMethodError: slick.driver.JdbcProfile$API.streamableQueryActionExtensionMethods(Lslick/lifted/Query;)Lslick/profile/BasicActionComp$$$$6aa48549c0a7603df1fa229cf7177493$$$$sionMethodsImpl;
        at models.daos.BaseDAO.getAll(BaseDAO.scala:62)
        at controllers.CategoryController$$anonfun$list$1.apply(CategoryController.scala:28)

def getAll : Future[Seq[A]] = {
    db.run(tableQ.result)
  }
斯卡拉基岛酒店

package models.daos

import models.entities.{Supplier, BaseEntity, Category, Product}
import models.persistence.SlickTables
import models.persistence.SlickTables.{SuppliersTable, BaseTable, CategoriesTable, ProductsTable}
import play.api.Play
import play.api.db.slick.{DatabaseConfigProvider, HasDatabaseConfig}
import slick.backend.DatabaseConfig
import slick.driver.JdbcProfile
import slick.lifted.{CanBeQueryCondition}
import scala.concurrent.Future
import play.api.libs.concurrent.Execution.Implicits.defaultContext

trait AbstractBaseDAO[T,A] {
  def insert(row : A): Future[Long]
  def insert(rows : Seq[A]): Future[Seq[Long]]
  def update(row : A): Future[Int]
  def update(rows : Seq[A]): Future[Unit]
  def findById(id : Long): Future[Option[A]]
  def findByFilter[C : CanBeQueryCondition](f: (T) => C): Future[Seq[A]]
  def deleteById(id : Long): Future[Int]
  def deleteById(ids : Seq[Long]): Future[Int]
  def deleteByFilter[C : CanBeQueryCondition](f:  (T) => C): Future[Int]
  def getAll() : Future[Seq[A]]
}


abstract class BaseDAO[T <: BaseTable[A], A <: BaseEntity]() extends AbstractBaseDAO[T,A] with HasDatabaseConfig[JdbcProfile] {
  protected lazy val dbConfig: DatabaseConfig[JdbcProfile] = DatabaseConfigProvider.get[JdbcProfile](Play.current)
  import dbConfig.driver.api._

  protected val tableQ: TableQuery[T]

  def insert(row : A): Future[Long] ={
    insert(Seq(row)).map(_.head)
  }

  def insert(rows : Seq[A]): Future[Seq[Long]] ={
    db.run(tableQ returning tableQ.map(_.id) ++= rows.filter(_.isValid))
  }

  def update(row : A): Future[Int] = {
    if (row.isValid)
      db.run(tableQ.filter(_.id === row.id).update(row))
    else
      Future{0}
  }

  def update(rows : Seq[A]): Future[Unit] = {
    db.run(DBIO.seq((rows.filter(_.isValid).map(r => tableQ.filter(_.id === r.id).update(r))): _*))
  }

  def findById(id : Long): Future[Option[A]] = {
    db.run(tableQ.filter(_.id === id).result.headOption)
  }

  def findByFilter[C : CanBeQueryCondition](f: (T) => C): Future[Seq[A]] = {
    db.run(tableQ.withFilter(f).result)
  }

  def getAll : Future[Seq[A]] = {
    db.run(tableQ.result)
  }

  def deleteById(id : Long): Future[Int] = {
    deleteById(Seq(id))
  }

  def deleteById(ids : Seq[Long]): Future[Int] = {
    db.run(tableQ.filter(_.id.inSet(ids)).delete)
  }

  def deleteByFilter[C : CanBeQueryCondition](f:  (T) => C): Future[Int] = {
    db.run(tableQ.withFilter(f).delete)
  }

}
使用./activator run编译

您尝试过这个吗(尽管我不确定您使用的是哪个播放版本)


您是如何编译/构建代码的?这看起来像是一个类路径问题,或者可能使用为不同的
Scala
版本编译的
Slick
版本?我已经进行了编辑,因此它显示了我的build.sbt,我正在使用activator run编译代码,我的目标是指向/tmp/project target的链接,因为使用encryptfs时出现了一个错误在linuxI中,在~/.sbt/0.13/local.sbt中有一个local.sbt文件,该文件中有一行说明ScalaOptions++=Seq(“-Xmax classfile name”,“78”)这是导致问题的原因,我在解决了另一个问题后忘记将其删除。不行。在我遇到文件名变长的问题之前,这工作正常,然后我还在playframework中更改了路由文件。您使用的是哪个播放版本?我升级到播放slick 2.0.0 witch随slick 3.1和play 2.5.0附带的slick 3.1和play 2.5.0 OK,这是否意味着p问题已经消失了(您对
sbt
中的更改的评论)?是的。问题是我在local.sbt中的条目减少了类文件名。感谢您的帮助。
version := "0.0.1"

lazy val root = (project in file(".")).enablePlugins(PlayScala)

scalaVersion := "2.11.8"

libraryDependencies ++= Seq(
  "com.typesafe.play" %% "play-slick" % "1.1.1",
  "com.typesafe.play" %% "play-slick-evolutions" % "1.1.1",
  evolutions,
  "com.h2database" % "h2" % "1.4.191",
  cache,
  ws,
  "org.scalatestplus.play" %% "scalatestplus-play" % "1.5.0-RC1" % Test
)

resolvers += "scalaz-bintray" at "http://dl.bintray.com/scalaz/releases"
libraryDependencies ++= Seq(
  "com.typesafe.play" %% "play-slick" % "2.0.0"
  "com.typesafe.play" %% "play-slick-evolutions" % "2.0.0"
)