我正在测试 Spring 缓存,这是我的上下文文件
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:cache="http://www.springframework.org/schema/cache"
xsi:schemaLocation=
"http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/cache http://www.springframework.org/schema/cache/spring-cache.xsd">
<cache:annotation-driven cache-manager="simpleCacheManager"/>
<bean id="simpleCacheManager" class="org.springframework.cache.support.SimpleCacheManager">
<property name="caches">
<set>
<bean class="org.springframework.cache.concurrent.ConcurrentCacheFactoryBean">
<property name="name" value="alfresco"/>
</bean>
<bean class="org.springframework.cache.concurrent.ConcurrentCacheFactoryBean">
<property name="name" value="alfresco_article"/>
</bean>
<bean class="org.springframework.cache.concurrent.ConcurrentCacheFactoryBean">
<property name="name" value="alfresco_action"/>
</bean>
</set>
</property>
</bean>
我添加了所有必需的库,但是我无法验证该库,因为 Eclipse 仍然告诉我缺少 AOPAlliance.jar 和 org.springframework.context-3.1.1.RELEASE.jar。
错误是:
在这一行找到多个注释:未找到 class org.springframework.cache.concurrent.ConcurrentCacheFactoryBean。
解决了更改为 org.springframework.cache.concurrent.ConcurrentMapCacheFactoryBean
但是,调用 url 会发生这种情况:
org.springframework.web.util.NestedServletException: Request processing failed; nested exception is org.springframework.beans.factory.BeanDefinitionStoreException: Unexpected exception parsing XML document from class path resource [configuration-context.xml]; nested exception is java.lang.NoClassDefFoundError: org/springframework/aop/config/AopNamespaceUtils
org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:894)
org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:778)
javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
root cause
org.springframework.beans.factory.BeanDefinitionStoreException: Unexpected exception parsing XML document from class path resource [configuration-context.xml]; nested exception is java.lang.NoClassDefFoundError: org/springframework/aop/config/AopNamespaceUtils
org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:412)
aop-alliance.jar 和 org.springframework.aop-3.1.1.RELEASE.jar 都在类路径中。
有什么线索吗?
Thanks,
Andrea
仔细检查 org.springframework.context-3.1.1.RELEASE.jar 确实位于类路径中。 Eclipse 验证和错误都指向此问题。
更新:我已经检查过了,你是对的。ConcurrentCacheFactoryBean
似乎自 3.1.0.M1 起已被删除,并可能被替换为ConcurrentMapCacheFactoryBean
在同一个包中。我还没有在发行说明中找到任何证据。但是,如果您将缓存的 bean 类名称更改为ConcurrentMapCacheFactoryBean
,它似乎工作得很好。
<bean class="org.springframework.cache.concurrent.ConcurrentMapCacheFactoryBean">
<property name="name" value="alfresco"/>
</bean>
UPDATE2:是的,确实如此ConcurrentCacheFactoryBean
已经renamed https://build.springsource.org/browse/SPR-MASTER-19/commit to ConcurrentMapCacheFactoryBean
.他们只是没有抽出时间来更新教程。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)