TypeSafe Slick是否适用于Scala 2.9.3?

Eme*_*gia 0 scala slick

TypeSafe Slick是否适用于Scala 2.9.3?我明白了

[ERROR] exception when typing query.list
exception when typing query.listscala.tools.nsc.symtab.Types$TypeError: class file needed by StatementInvoker is missing.
[INFO] class file needed by StatementInvoker is missing.
[INFO] reference type Either of object package refers to nonexisting symbol.
Run Code Online (Sandbox Code Playgroud)

当我使用Scala 2.10.x时它会消失,但我对Scala来说太新了解了解原因.

import slick.session.Database
import scala.slick.jdbc.StaticQuery
import Database.threadLocalSession
import com.typesafe.config.ConfigFactory

object PostgresDao {

  protected val conf = ConfigFactory.load

  def findFoo(a: Int, b: String): Option[Int] = {

    Database.forURL("jdbc:postgresql://localhost/bar", driver = "org.postgresql.Driver") withSession {

      val query = StaticQuery.query[(Int, String), Int](
        """
        select some_int
        from some_table t
        where t.a = ? and t.b = ?
        """.stripMargin)

      val list: List[Int] = query.list((a, b))

      if (list.isEmpty) {
        None
      }
      else {
        Some(list.head)
      }
    }
  }
Run Code Online (Sandbox Code Playgroud)

om-*_*nom 5

我在这里无耻地复制过去的官方文件:

Slick需要Scala 2.10.(对于Scala 2.9,请使用Slick的前身ScalaQuery).