我想使用simple-spring-memcached来缓存数据。所以使用这个https://code.google.com/p/simple-spring-memcached/wiki/Getting_Started为我的目的。 我添加了我的dispatcher-servlet.xml
<aop:aspectj-autoproxy />
<import resource="simplesm-context.xml" />
<bean name="cacheManager" class="com.google.code.ssm.spring.SSMCacheManager">
<property name="caches">
<set>
<bean class="com.google.code.ssm.spring.SSMCache">
<constructor-arg name="cache" index="0" ref="defaultCache"/>
<!-- 5 minutes -->
<constructor-arg name="expiration" index="1" value="0"/>
<!-- @CacheEvict(..., "allEntries" = true) doesn't work -->
<constructor-arg name="allowClear" index="2" value="false"/>
</bean>
</set>
</property>
</bean>
<bean name="defaultCache" class="com.google.code.ssm.CacheFactory">
<property name="cacheName" value="defaultCache"/>
<property name="cacheClientFactory">
<bean name="cacheClientFactory" class="com.google.code.ssm.providers.xmemcached.MemcacheClientFactoryImpl"/>
</property>
<property name="addressProvider">
<bean class="com.google.code.ssm.config.DefaultAddressProvider">
<property name="address" value="127.0.0.1:11211"/>
</bean>
</property>
<property name="configuration">
<bean class="com.google.code.ssm.providers.CacheConfiguration">
<property name="consistentHashing" value="true"/>
</bean>
</property>
</bean>
我还将simple-spring-memcached-3.5.0.jar和spymemcache.jar,spymemcache-provider.jar添加到lib文件夹中。但是当我运行我的项目时会发生以下异常:
Cannot find class **[net.nelz.simplesm.config.MemcachedClientFactory]** for bean with name 'memcachedClientFactory' defined in ServletContext resource [/WEB-INF/simplesm-context.xml]; nested exception is java.lang.ClassNotFoundException: net.nelz.simplesm.config.MemcachedClientFactory
答案 0 :(得分:1)
你必须为这个类添加lib。
答案 1 :(得分:0)
在你的类路径中你也有一个旧版本的Simple Spring Memcached。 3.x中不再提供班级net.nelz.simplesm.config.MemcachedClientFactory
。检查您的类路径并删除所有早于3.5.0的Simple Spring Memcached工件。