Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/353.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/1/typo3/2.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
Ehcache无法使用java中的泛型类进行初始化_Java_Ehcache_Ehcache 3 - Fatal编程技术网

Ehcache无法使用java中的泛型类进行初始化

Ehcache无法使用java中的泛型类进行初始化,java,ehcache,ehcache-3,Java,Ehcache,Ehcache 3,我使用了Ehcache 3,并将缓存声明为: private Cache<String,GenericClassForList<Person>> personCache; 私有缓存personCache; 例如:我有许多要放入缓存的对象列表,它们来自数据库: List<Person> personlist=perDao.getAll(); List<Customer> custList=comDao.getAll(); List<Com

我使用了Ehcache 3,并将缓存声明为:

 private Cache<String,GenericClassForList<Person>> personCache;
私有缓存personCache;
例如:我有许多要放入缓存的对象列表,它们来自数据库:

List<Person> personlist=perDao.getAll();
List<Customer> custList=comDao.getAll();
List<Company> companylist=compDao.getAll();
List personlist=perDao.getAll();
List custList=comDao.getAll();
List companylist=compDao.getAll();
因此,我需要将这些不同类型的列表放入缓存中。因此,我尝试使用泛型类将这些列表初始化为:

package com.cache.cachemanager;


import java.util.ArrayList;
import java.util.Collection;

public class GenericClassForList<T> extends ArrayList<T> {

    public GenericClassForList(final Collection<? extends T> c) {
        super(c);
    }


}
package com.cache.cachemanager;
导入java.util.ArrayList;
导入java.util.Collection;
公共类GenericClassForList扩展了ArrayList{

public GenericClassForList(最终集合,错误消息显示将
GenericClassForList.class
替换为
GenericClassForList.class

为什么编译器不允许它。因为


“类型擦除可确保不会为参数化类型创建新类;因此,泛型不会产生运行时开销”

因为错误消息显示将GenericClassForList.class替换为GenericClassForList.class
    public class CacheHelper {

        private CacheManager cacheManager;

        private Cache<String,GenericClassForList<Person>> personCache;


        public CacheHelper() {

        }

        //initialziing cache
        public void putInCacheFromDb() {
            System.getProperties().setProperty("java -Dnet.sf.ehcache.use.classic.lru", "true");
            cacheManager= CacheManagerBuilder
                    .newCacheManagerBuilder().build();
            cacheManager.init();

           personCache = cacheManager
                    .createCache("cacheOfe", CacheConfigurationBuilder
                            .newCacheConfigurationBuilder(
                                    String.class,GenericClassForList<Person>.class,
                                    ResourcePoolsBuilder.heap(100000)).withExpiry(Expirations.timeToLiveExpiration(Duration.of(60000,
                                    TimeUnit.SECONDS))));
        }
}
.newCacheConfigurationBuilder(
                                String.class,GenericClassForList<Person>.class,