Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/11.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/jsp/3.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 Spring-ehcache-#root.targetClass值,如果返回类型为List<;用户>;?_Java_Spring_Ehcache - Fatal编程技术网

Java Spring-ehcache-#root.targetClass值,如果返回类型为List<;用户>;?

Java Spring-ehcache-#root.targetClass值,如果返回类型为List<;用户>;?,java,spring,ehcache,Java,Spring,Ehcache,我有以下方法: @Cacheable(value="settings", key = "#root.targetClass") @Override public List<MySeeting> getAll() { return Lists.newArrayList(settingRepository.findAll()); } @Cacheable(value=“settings”,key=“#root.targetClass”) @凌驾 公共列表getAll(){

我有以下方法:

@Cacheable(value="settings", key = "#root.targetClass")
@Override   
public List<MySeeting> getAll() {
    return Lists.newArrayList(settingRepository.findAll());
}
@Cacheable(value=“settings”,key=“#root.targetClass”)
@凌驾
公共列表getAll(){
return Lists.newArrayList(settingRepository.findAll());
}
#root.targetClass的值是多少? 列出或MySeeting

我正在使用Spring4和ehcache

干杯

根据
targetClass
是被调用目标的类,即调用方法的对象的类型。所以它与方法的返回类型无关


在任何情况下,由于Java中的泛型擦除,访问返回类型只会给您类型
列表

我找到了我正在寻找的答案,我在谷歌上发现了以下代码:

public void getCache() {
    Object nativeCache = cacheManager.getCache("mycache").getNativeCache();

    if (nativeCache instanceof net.sf.ehcache.Ehcache) {
        net.sf.ehcache.Ehcache ehCache = (net.sf.ehcache.Ehcache) nativeCache;
        ehCache.getKeys();
      }
}
通过检查“ehCache.getKeys()”,我可以看到“#root.targetClass”实际上是“class com.test.service.impl.MyService”(MyService类是声明上述getAll方法的地方)