我試圖實現緩存彈簧3.0的Ehcache與Spring Configruation +的JdbcTemplate
下面是相關的整合代碼:
<bean id="cacheManager" class="net.sf.ehcache.CacheManager">
<constructor-arg index="0" type="java.net.URL" value="classpath:ehcache.xml"/>
</bean>
在應用程序context.xml文件
我有一個有效的ehcache.xml文件,但它從未讀取,因爲應用程序炸彈在它到達那裏之前,我收到的錯誤如下:
org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class [net.sf.ehcache.CacheManager] for bean with name 'cacheManager' defined in ServletContext resource [/WEB-INF/spring/application-context.xml]; nested exception is java.lang.ClassNotFoundException: net.sf.ehcache.CacheManager
at org.springframework.beans.factory.support.AbstractBeanFactory.resolveBeanClass(AbstractBeanFactory.java:1208)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.predictBeanType(AbstractAutowireCapableBeanFactory.java:568)
at org.springframework.beans.factory.support.AbstractBeanFactory.isFactoryBean(AbstractBeanFactory.java:1277)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeanNamesForType(DefaultListableBeanFactory.java:302)
at org.springframework.beans.factory.BeanFactoryUtils.beanNamesForTypeIncludingAncestors(BeanFactoryUtils.java:185)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.findAutowireCandidates(DefaultListableBeanFactory.java:805)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:762)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:680)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredMethodElement.inject(AutowiredAnnotationBeanPostProcessor.java:556)
... 30 more
Caused by: java.lang.ClassNotFoundException: net.sf.ehcache.CacheManager
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1645)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1491)
at org.springframework.util.ClassUtils.forName(ClassUtils.java:258)
at org.springframework.beans.factory.support.AbstractBeanDefinition.resolveBeanClass(AbstractBeanDefinition.java:408)
at org.springframework.beans.factory.support.AbstractBeanFactory.doResolveBeanClass(AbstractBeanFactory.java:1229)
at org.springframework.beans.factory.support.AbstractBeanFactory.resolveBeanClass(AbstractBeanFactory.java:1200)
有沒有人有我做錯什麼的想法?
我目前的Ehcache的版本是1.6.1,雖然我甲肝加入了Ehcache-1.6.1.jar BT仍然沒有工作,我應該發佈我的應用程序context.xml文件。我認爲我做錯了dere。 – Anurag 2012-01-18 09:02:28
我不認爲發佈你的applicationContext.xml會有所幫助。我添加了你應該使用的確切的maven依賴。嘗試一下。 – yair 2012-01-18 12:58:26