And*_*rdi 8 java eclipse spring caching java-ee
我正在测试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>
Run Code Online (Sandbox Code Playgroud)
我添加了所有必需的库但是,我无法验证库,因为Eclipse仍然告诉我AOPAlliance.jar和org.springframework.context-3.1.1.RELEASE.jar缺失.
错误是:
在此行找到多个注释:找不到类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)
Run Code Online (Sandbox Code Playgroud)
aop-alliance.jar和org.springframework.aop-3.1.1.RELEASE.jar都在classpath中.
任何线索?
谢谢,
安德烈
mak*_*mov 20
仔细检查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>
Run Code Online (Sandbox Code Playgroud)
更新2:是的,确实ConcurrentCacheFactoryBean已经重命名为ConcurrentMapCacheFactoryBean.他们只是没有到处更新教程.
| 归档时间: |
|
| 查看次数: |
6944 次 |
| 最近记录: |