我正在尝试插入此处提到的 cache-annotations-ri-guice 。我找到了描述。但它不起作用。我的测试项目看起来像
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();
}
}
此调用每次返回不同的值。
构建.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"
模块.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
如何让它正常工作?