Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java @用于'的可缓存使用SpEL;价值';提出?_Java_Spring_Ehcache_Spring El - Fatal编程技术网

Java @用于'的可缓存使用SpEL;价值';提出?

Java @用于'的可缓存使用SpEL;价值';提出?,java,spring,ehcache,spring-el,Java,Spring,Ehcache,Spring El,以下是一段代码片段: @Cacheable(value = "employee", key = "#surname") public Person findEmployeeBySurname(String firstName, String surname, int age) { return new Person(firstName, surname, age); } 看起来“key”字段支持SpEL,我想知道是否可以在“value”字段中使用SpEL

以下是一段代码片段:

  @Cacheable(value = "employee", key = "#surname")
  public Person findEmployeeBySurname(String firstName, 
        String surname, int age) {
     return new Person(firstName, surname, age);
  }

看起来“key”字段支持SpEL,我想知道是否可以在“value”字段中使用SpEL?原因是-我不想在@Cacheable中硬编码“cache name”,但“value”也不支持从属性或使用Apache公共配置加载缓存名称。所以,我只是在寻找是否有任何方法可以避免硬编码“缓存名称”并使用SpEL。TIA

如果您使用的是Spring 4.1,您可以尝试使用
CacheResolver
。看

我们在JSR-107中发现的最好的特性之一是 解析要在运行时使用的缓存,该缓存基于实际 方法执行