0
我正在試圖像上面提到的here那樣插入cache-annotations-ri-guice。我發現了description。但它不起作用。 我的測試項目看起來像用guice在playframework中緩存註釋
public class HomeController extends Controller {
public Result index() {
return ok(getString("qwe"));
}
@CacheResult
private String getString(String str) {
Random r = new Random();
return "HelloWorld " + str + r.nextInt();
}
}
此調用每次返回的值不同。
build.sbt:
name := """myann"""
organization := "com.example"
version := "1.0-SNAPSHOT"
lazy val root = (project in file(".")).enablePlugins(PlayJava, PlayNettyServer, LauncherJarPlugin)
.disablePlugins(PlayAkkaHttpServer)
.settings(libraryDependencies ++= Seq(
guice,
jcache,
ehcache,
"org.jsr107.ri" % "cache-annotations-ri-guice" % "1.0.0"
))
scalaVersion := "2.12.2"
Module.java:
public class Module extends AbstractModule {
@Override
public void configure() {
install(new CacheAnnotationsModule());
}
}
我的環境: addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.6.3") sbt.version=0.13.15
如何使它能正常運行?