繁体   English   中英

Scala build.sbt:用于播放框架 2.8.6 的 Memcached 插件

[英]Scala build.sbt: Memcached Plugin for Play framework 2.8.6

我正在尝试将mumoshu 的 Memcached Plugin for Play framework升级到Play 2.8.6 ,在build.sbt中。

升级说明如下:

对于 Play 2.6.x 和更新版本: ... 将 play.modules.cache.* 配置键更改为 play.cache.* !!!

val appDependencies = Seq(
  play.PlayImport.cacheApi,
  "com.github.mumoshu" %% "play2-memcached-play26" % "0.9.2"
)
val main = Project(appName).enablePlugins(play.PlayScala).settings(
  version := appVersion,
  libraryDependencies ++= appDependencies,
  resolvers += "Spy Repository" at "http://files.couchbase.com/maven2" // required to resolve `spymemcached`, the plugin's dependency.
)

在升级之前,我有:

libraryDependencies ++= Seq(
  jdbc,
  cache,
  ws,  
  "com.github.mumoshu" %% "play2-memcached-play24" % "0.7.0",
  //...
}

(不成功)升级后:

  • cache依赖没有解决,所以我删除了它。

更新后的build.sbt现在看起来像这样:

name := "CH07"

version := "1.0"

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

scalaVersion := "2.13.4"

resolvers += "Spy Repository" at "http://files.couchbase.com/maven2"

val appDependencies = Seq(
  play.sbt.PlayImport.cache,
  "com.github.mumoshu" %% "play2-memcached-play28" % "0.11.0"
  //"com.github.mumoshu" %% "play2-memcached-play26" % "0.9.2"
)
val main = (project in file(".")).enablePlugins(play.sbt.PlayScala).settings(
  version := version.value,
  libraryDependencies ++= appDependencies,
  resolvers += "Spy Repository" at "http://files.couchbase.com/maven2" // required to resolve `spymemcached`, the plugin's dependency.
)

libraryDependencies ++= Seq(
  jdbc,
  //cache,
  ws,

  "org.hsqldb" % "hsqldb" % "2.5.0",
  "org.jooq" % "jooq" % "3.14.4",
  "org.jooq" % "jooq-codegen-maven" % "3.14.4",
  "org.jooq" % "jooq-meta" % "3.14.4",
  "joda-time" % "joda-time" % "2.7",
  "com.github.ironfish" %% "akka-persistence-mongo-casbah"  % "0.7.6",
  "com.ning" % "async-http-client" % "1.9.29"
)

routesGenerator := InjectedRoutesGenerator

我得到的错误:

* build.sbt:
error: value cache is not a member of object play.sbt.PlayImport

* build.sbt:
"com.github.mumoshu" %% "play2-memcached-play28" % "0.11.0"
Intellij says: unresolved artifact. Not resolved or indexed.

* in project/plugins.sbt:
addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.8.6")
Intellij says: unresolved artifact. Not resolved or indexed.

你能看到我在build.sbt中犯的任何错误吗?

换句话说,我正在为使用 Play 2.8.6 和 Memcached Plugin for Play 框架 0.9.2 的项目寻找一个有效的build.sbt (和其他必需的定义)示例。 (或后者的最高版本)。

更新:

这是我当前编译的配置:

构建.sbt

name := "CH07"

version := "1.0"

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

scalaVersion := "2.13.4"

resolvers += "Spy Repository" at "http://files.couchbase.com/maven2"

libraryDependencies ++= Seq(
  jdbc,
  cacheApi,
  ws,
  "com.github.mumoshu" %% "play2-memcached-play28" % "0.11.0",
  "org.hsqldb" % "hsqldb" % "2.5.0",
  "org.jooq" % "jooq" % "3.14.4",
  "org.jooq" % "jooq-codegen-maven" % "3.14.4",
  "org.jooq" % "jooq-meta" % "3.14.4",
  "joda-time" % "joda-time" % "2.7",
  "com.ning" % "async-http-client" % "1.9.29",
  "com.github.scullxbones" %% "akka-persistence-mongo-common" % "3.0.5",
  "com.typesafe.akka" %% "akka-persistence" % "2.6.10",
  "com.typesafe.akka" %% "akka-persistence-query" % "2.6.10",
  "com.typesafe.akka" %% "akka-persistence-typed" % "2.6.10",
  "com.typesafe.play" %% "play-guice" % "2.8.7"
)

routesGenerator := InjectedRoutesGenerator

项目/build.properties

sbt.version=1.3.10

项目/插件.sbt

addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.8.7")

这个怎么样?

name := """pla-memcache-example"""
organization := "com.example"

version := "1.0-SNAPSHOT"

scalaVersion := "2.13.3"

val appDependencies = Seq(
    guice,
    play.PlayImport.cacheApi,
    "com.github.mumoshu" %% "play2-memcached-play28" % "0.11.0",
    "org.scalatestplus.play" %% "scalatestplus-play" % "5.0.0" % Test
)

lazy val root = (project in file(".")).enablePlugins(PlayScala).settings(
    version := appVersion,
    libraryDependencies ++= appDependencies,
    resolvers += "Spy Repository" at "http://files.couchbase.com/maven2" // required to resolve `spymemcached`, the plugin's dependency.
  )

插件.sbt

sbt.version=1.3.13

插件.sbt

addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.8.7")

在这种情况下,首先找到 giter8 模板并使用“sbt new”命令。 接下来,go到插件官方页面查看库名,然后使用Maven搜索找到你要使用的版本。 阅读插件的整个自述文件而不跳过它是个好主意。

您也可以尝试使用命令而不是使用 IntelliJ 来运行 sbt。
如果这不能解决问题,您可以尝试清除 .ivy2 目录中的缓存。

参考链接:
https://github.com/mumoshu/play2-memcached
https://github.com/playframework/play-scala-seed.g8
https://search.maven.org/artifact/com.github.mumoshu/play2-memcached-play28_211。

您的问题是在尝试导入play.sbt.PlayImport.cache时。 根据Cache APIs Migration by play:

新包

现在,`cache` 已被拆分为仅包含 API 的 `cacheApi` 组件和包含 Ehcache 实现的 `ehcache`。 如果您使用默认的 Ehcache 实现,只需在 `build.sbt` 中将 `cache` 更改为 `ehcache`:
 libraryDependencies ++= Seq( ehcache )

如果您正在定义自定义缓存 API,或者正在编写缓存实现模块,您可以只依赖 API:

 libraryDependencies ++= Seq( cacheApi )

移除的 API

已弃用的 Java class play.cache.Cache 已删除,您现在必须注入 play.cache.SyncCacheApi 或 play.cache.AsyncCacheApi。

因此,完整的build.sbt将是:

name := "CH07"

version := "1.0"

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

scalaVersion := "2.13.4"

resolvers += "Spy Repository" at "https://files.couchbase.com/maven2"

val appDependencies = Seq(
  play.sbt.PlayImport.ehcache,
  play.sbt.PlayImport.cacheApi,
  "com.github.mumoshu" %% "play2-memcached-play28" % "0.11.0"
  //"com.github.mumoshu" %% "play2-memcached-play26" % "0.9.2"
)
val main = (project in file(".")).enablePlugins(play.sbt.PlayScala).settings(
  version := version.value,
  libraryDependencies ++= appDependencies,
  resolvers += "Spy Repository" at "https://files.couchbase.com/maven2" // required to resolve `spymemcached`, the plugin's dependency.
)

libraryDependencies ++= Seq(
  jdbc,
  //cache,
  ws,

  "org.hsqldb" % "hsqldb" % "2.5.0",
  "org.jooq" % "jooq" % "3.14.4",
  "org.jooq" % "jooq-codegen-maven" % "3.14.4",
  "org.jooq" % "jooq-meta" % "3.14.4",
  "joda-time" % "joda-time" % "2.7",
  "com.github.scullxbones" %% "akka-persistence-mongo-common" % "3.0.5",
  "com.ning" % "async-http-client" % "1.9.29"
)

routesGenerator := InjectedRoutesGenerator

build.properties

sbt.version=1.4.4

plugins.sbt

logLevel := Level.Warn

resolvers += "Typesafe repository" at "https://repo.typesafe.com/typesafe/releases/"

addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.8.7")

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM