簡體   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