我尝试从第3.1版升级到第4.1版,但是Ehcache配置遇到了问题。以下是例外:
Caused by: org.springframework.beans.factory.BeanCreationException:
Error creating bean with name
'com.googlecode.ehcache.annotations.impl.CacheAttributeSourceImpl#0':
Initialization of bean failed; nested exception is
org.springframework.beans.ConversionNotSupportedException: Failed to
convert property value of type
'org.springframework.cache.ehcache.EhCacheCacheManager' to required
type 'net.sf.ehcache.CacheManager' for property 'cacheManager'; nested
exception is java.lang.IllegalStateException: Cannot convert value of
type [org.springframework.cache.ehcache.EhCacheCacheManager] to
required type [net.sf.ehcache.CacheManager] for property
'cacheManager': no matching editors or conversion strategy found at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:547)
at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:476)
at
org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:303)
at
org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
at
org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:299)
at
org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)
at
org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:351)
... 49 more Caused by:
org.springframework.beans.ConversionNotSupportedException: Failed to
convert property value of type
'org.springframework.cache.ehcache.EhCacheCacheManager' to required
type 'net.sf.ehcache.CacheManager' for property 'cacheManager'; nested
exception is java.lang.IllegalStateException: Cannot convert value of
type [org.springframework.cache.ehcache.EhCacheCacheManager] to
required type [net.sf.ehcache.CacheManager] for property
'cacheManager': no matching editors or conversion strategy found at
org.springframework.beans.BeanWrapperImpl.convertIfNecessary(BeanWrapperImpl.java:476)
at
org.springframework.beans.BeanWrapperImpl.convertForProperty(BeanWrapperImpl.java:512)
at
org.springframework.beans.BeanWrapperImpl.convertForProperty(BeanWrapperImpl.java:506)
at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.convertForProperty(AbstractAutowireCapableBeanFactory.java:1523)
at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1482)
at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1222)
at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:537)
... 55 more Caused by: java.lang.IllegalStateException: Cannot
convert value of type
[org.springframework.cache.ehcache.EhCacheCacheManager] to required
type [net.sf.ehcache.CacheManager] for property 'cacheManager': no
matching editors or conversion strategy found at
org.springframework.beans.TypeConverterDelegate.convertIfNecessary(TypeConverterDelegate.java:287)
at
org.springframework.beans.BeanWrapperImpl.convertIfNecessary(BeanWrapperImpl.java:461)
答案 0 :(得分:0)
您的设置中看起来间接太少了。评论中的配置摘录似乎与documented匹配。
因此,我建议您使用完整的Spring配置编辑问题,以确保没有其他元素导致此错误。
错误来自您希望consume
缓存管理器实例的位置。为了获得Ehcache的支持CacheManager
,您需要从EhCacheCacheManager.getCacheManager
bean访问cache-manager
。
bean com.googlecode.ehcache.annotations.impl.CacheAttributeSourceImpl#0
期望属性cache-manager
具有不同的类型。也许那个bean源 - 我假设的库 - 需要更新以匹配Spring的版本。