2015-04-20 5 views
0

Я пытаюсь обновиться с весны 3.1 до весны 4.1, но в конфигурации Ehcache возникла проблема. Ниже приведено исключение:Spring4 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

Да, я определил – xufeng

+0

<боб ID = класс "cacheManager" = "org.springframework.cache.ehcache.EhCacheCacheManager" р: кэш-менеджер-исх = "EHCache" /> \t <- Ehcache установка библиотеки! -> \t xufeng

ответ

0

Похоже, у вас слишком мало косвенности в настройках. Экземпляр конфигурации в вашем комментарии, похоже, соответствует тому, что есть documented.

Поэтому я бы предложил изменить свой вопрос с помощью полной конфигурации Spring, чтобы убедиться, что у вас нет других элементов, вызывающих эту ошибку.

Ошибка возникает из того, где вы хотите consume экземпляр менеджера кэша. Чтобы добраться до базы CacheManager из Ehcache, вам необходимо получить доступ к EhCacheCacheManager.getCacheManager из вашего бока cache-manager. Фасоль com.googlecode.ehcache.annotations.impl.CacheAttributeSourceImpl#0 ожидает, что свойство cache-manager будет другого типа. Возможно, этот источник bean - библиотека, которую я предполагаю, нуждается в обновлении в соответствии с версией Spring.

Смежные вопросы