2017-08-30 1 views
0

J'essaie de greffer cache-annotations-ri-guice comme mentionné here. J'ai trouvé un description. Mais ça ne marche pas. Mon projet de test ressembleAnnotations de cache dans playframework avec 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(); 
} 
} 

Cet appel à chaque fois renvoie des valeurs différentes.

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()); 
} 
} 

Mon environnement: addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.6.3") sbt.version=0.13.15 Comment faire fonctionner régulièrement?

Répondre

0

Cette annotation ne fonctionne pas pour les méthodes privées.