【问题标题】:Play framework 2.5 - scala oauth2 provider issue播放框架 2.5 - scala oauth2 提供程序问题
【发布时间】:2016-05-06 15:22:02
【问题描述】:

我做了什么:

我正在尝试使用 Play 框架实现 oauth2 提供程序。我正在使用“scala-oauth2-provider”示例来执行此操作。 "https://github.com/nulab/scala-oauth2-provider"

我列出了我在应用程序中使用的版本:

播放 -- 2.5

数据库——Mysql 5.1.22

问题:

AuthCode.scala:19: 找不到参数 tm 的隐式值: scala.slick.ast.TypedType[org.joda.time.DateTime] [错误] def createdAt = columnDateTime

代码片段:

import java.util.UUID
import org.joda.time.DateTime
import scala.slick.driver.MySQLDriver.simple._

case class AuthCode(authorizationCode: String, userGuid: UUID, redirectUri: Option[String], createdAt: DateTime, scope: Option[String], clientId: Option[String], expiresIn: Int)

class AuthCodes(tag: Tag) extends Table[AuthCode](tag, "auth_codes") {
  def authorizationCode = column[String]("authorization_code", O.PrimaryKey)
  def userGuid = column[UUID]("user_guid")
  def redirectUri = column[Option[String]]("redirect_uri")
  def createdAt = column[DateTime]("created_at")
  def scope = column[Option[String]]("scope")
  def clientId = column[Option[String]]("client_id")
  def expiresIn = column[Int]("expires_in")
  def * = (authorizationCode, userGuid, redirectUri, createdAt, scope, clientId, expiresIn) <> (AuthCode.tupled, AuthCode.unapply)
}

我该如何解决这个问题?谁能帮我解决这个问题?

注意:我也尝试了解决方案https://stackoverflow.com/a/22578950/1584121。但是我遇到了同样的问题:(

【问题讨论】:

  • @cchantep 不,这并没有解决我的问题。我已经应用了这两种解决方案。但是遇到了同样的问题。
  • 我已经通过添加以下导入语句解决了这个问题。导入 com.github.tototoshi.slick.MySQLJodaSupport._

标签: mysql scala oauth-2.0 playframework-2.5


【解决方案1】:

我没有查看示例项目,但我使用了通过https://github.com/tototoshi/slick-joda-mapper 提供的解决方案。希望您可以将其应用于您的代码。我将 Scala 2.11.8 与 Slick 3.1.1 一起使用,因此使用 slick-joda-mapper 2.2.0。如果您使用不同版本的 Scala 和/或 Slick,您可能需要选择不同版本的 slick-joda-mapper。

首先将所需的依赖项添加到您的build.sbt

libraryDependencies ++= Seq(
    "com.typesafe.slick" %% "slick" % "3.1.1",
    "org.slf4j" % "slf4j-nop" % "1.6.4",
    "com.github.tototoshi" %% "slick-joda-mapper" % "2.2.0",
    "joda-time" % "joda-time" % "2.7",
    "org.joda" % "joda-convert" % "1.7"
)

在您的 Scala 源文件中,使用以下导入:

import slick.driver.MySQLDriver.api._
import scala.concurrent.ExecutionContext.Implicits.global
import com.github.tototoshi.slick.MySQLJodaSupport._
import org.joda.time.DateTime

然后您可以在 Slick 查询中使用 DateTime 对象。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2014-07-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-08-03
    相关资源
    最近更新 更多