Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/389.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 通过XML配置SpringEHcache 3.x_Java_Spring_Ehcache_Jcache - Fatal编程技术网

Java 通过XML配置SpringEHcache 3.x

Java 通过XML配置SpringEHcache 3.x,java,spring,ehcache,jcache,Java,Spring,Ehcache,Jcache,我正在尝试使用SpringXML上下文注入Ehcache(v3.9)javax.cache.CacheManager(JSR-107 JCacheAPI)。 初步尝试: 由于java.lang.IllegalArgumentException失败:无法检索类路径资源[WEB-INF/ehcache.xml]的URI:类路径资源[WEB-INF/ehcache.xml]无法解析为URL,因为它不存在 我仅使用适配器类成功地做到了这一点: import java.io.IOException;

我正在尝试使用SpringXML上下文注入Ehcache(v3.9)
javax.cache.CacheManager
(JSR-107 JCacheAPI)。 初步尝试:


由于
java.lang.IllegalArgumentException失败:无法检索类路径资源[WEB-INF/ehcache.xml]的URI:类路径资源[WEB-INF/ehcache.xml]无法解析为URL,因为它不存在

我仅使用适配器类成功地做到了这一点:

import java.io.IOException;
导入javax.cache.CacheManager;
导入javax.cache.spi.CachingProvider;
导入org.springframework.core.io.Resource;
公共类CacheManagerFactory{
私有最终资源配置位置;
私人最终CachingProvider CachingProvider;
公共缓存管理器工厂(CachingProvider CachingProvider,资源配置位置){
this.configurationLocation=configurationLocation;
this.cachingProvider=cachingProvider;
}
公共缓存管理器getCacheManager(){
试一试{
返回此.cachingProvider.getCacheManager(this.configurationLocation.getURI(),this.getClass().getClassLoader());
}捕获(IOEX异常){
抛出新的运行时异常(“缺少配置”,ex);
}
}
}
在春天的背景下:


问题是将“/WEB-INF/ehcache.xml”指定为相对于webapp root的URI,作为
org.ehcache.jsr107.ehcachechingprovider#getCacheManager()
方法的参数


是否可以在没有包装类的情况下进行注入?

WEB-INF
不是类路径。只需删除
类路径:
前缀,它就会将其加载或移动到类路径(即在
src/main/resources
中),使其成为类路径的一部分。@M.Deinum我面临一个问题