Play framework + SLICK (Scalaquery) tutorial

后端 未结 2 1826
春和景丽
春和景丽 2021-02-02 14:57

Does anybody know of a good tutorial or a sample project (github) of using Play framework with SLICK (ScalaQuery)? I am struggling to make them work together.

I am getti

2条回答
  •  迷失自我
    2021-02-02 15:12

    Edit Now that Play2.1 has entered its RC process, we can use Slick. That's because Play2.1 is using Scala2.10 (RC as well) under the sea and because Slick will be the default DB access lib in the Typesafe stack.

    To recall, Slick is now able to access RDBMS, and will target soon MongoDB as well. It's using a slick (^^) internal DSL for querying backends. This DSL is managed by Macros, that's why Scala 2.10 is required.

    However, note that the macro system is in experimental status (even when Scala2.10 will be released). I don't know yet the potential caveats of such status on the Slick lib in the near future.

    To enjoy this RC, go there Play2.1RC1, and browse the doc... there are a lot of changes out there, like the Json API f.i.


    Hmmmm. Not sure that slick will work out of the box with Play as easy.

    Because PLay 2.0 is actually build upon Scala 2.9.x, where slick is requiring 2.10 (for Macro).

    So, at first there is a mismatch between the deps you're declaring (slick_2.10.0-M4 is saying I'm using Scala 2.10.0-M4) and the scala version that'll be used.

    BTW, according to this example site (for Slick) your SBT deps seems ok. But the problem might come that the driver will required other deps (AST probably) and leave SBT discover the right version using the current scala version you're using (this is done by declaring dependency without scala version in the "articfact name") => This case, the AST won't be found because it doesn't exists for pre-2.10.

    What could be tried is to define another version of scala for the whole project...

    My 2c

提交回复
热议问题