0

WHAT I DID:

I am trying to implement oauth2 provider using Play framework. I am using the "scala-oauth2-provider" sample to do this. "https://github.com/nulab/scala-oauth2-provider"

I have listed the version that I used in my application:

Play -- 2.5

database -- Mysql 5.1.22

ISSUE:

AuthCode.scala:19: could not find implicit value for parameter tm: scala.slick.ast.TypedType[org.joda.time.DateTime] [error] def createdAt = columnDateTime

Code Snippet:

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)
}

How do I fix this issue? Can anyone help me to fix this issue?

Note: I have also tried the solution https://stackoverflow.com/a/22578950/1584121. But I am getting same issue :(

Community
  • 1
  • 1
SKK
  • 1,705
  • 3
  • 28
  • 50
  • Possible duplicate of [How to use DateTime in Slick2.0?](http://stackoverflow.com/questions/22578501/how-to-use-datetime-in-slick2-0) – cchantep May 06 '16 at 16:19
  • @cchantep No. That didn't solve my issue. I have applied the two solution. But got the same issue. – SKK May 08 '16 at 16:42
  • I have fixed the issue by adding the below import statement. import com.github.tototoshi.slick.MySQLJodaSupport._ – SKK May 08 '16 at 18:00

1 Answers1

1

I didn't look into the sample project, but I used the solution available through https://github.com/tototoshi/slick-joda-mapper. Hopefully you can apply this to your code. I am using Scala 2.11.8 with Slick 3.1.1, and therefore use slick-joda-mapper 2.2.0. If you are using different versions of Scala and/or Slick, you might have to select a different version of slick-joda-mapper.

First add the required dependencies to your 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"
)

In your Scala source file, use the following imports:

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

You can then use a DateTime object simply in Slick queries.

Benjamin
  • 89
  • 3