无法将类型'java.lang.String'的属性值转换为属性'cacheManager'所需的类型'net.sf.ehcache.CacheManager'
<bean id="cacheManager" class="org.springframework.cache.ehcache.EhCacheCacheManager" p:cache-manager="ehcache"/>
<!-- Ehcache library setup -->
<bean id="ehcache" class="org.springframework.cache.ehcache.EhCacheManagerFactoryBean" p:config-location="classpath:com/spring/test/ehcache/config/ehcache.xml"/>
答案 0 :(得分:8)
p:cache-manager
不适用于bean引用。试试这个:
<bean id="cacheManager" class="org.springframework.cache.ehcache.EhCacheCacheManager">
<property name="cacheManager" ref="ehcache"/>
</bean>
<bean id="ehcache" class="org.springframework.cache.ehcache.EhCacheManagerFactoryBean">
<property name="configLocation" value="classpath:com/spring/test/ehcache/config/ehcache.xml"/>
</bean>
答案 1 :(得分:6)
或者您可以使用Spring p-namespace
的正确方法<bean id="cacheManager" class="org.springframework.cache.ehcache.EhCacheCacheManager" p:cache-manager-ref="ehcache"/>